VirtualBox

Changeset 10980 in vbox for trunk/src/VBox/Additions


Ignore:
Timestamp:
Jul 30, 2008 1:13:20 PM (16 years ago)
Author:
vboxsync
Message:

Runtime, HostServices/GuestProperties, Additions/common: autores update

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibGuestProp.cpp

    r10976 r10980  
    533533{
    534534    int rc = VINF_SUCCESS;
    535     RTMemAutoPtr<VBGLR3GUESTPROPENUM, VbglR3GuestPropEnumFree> apHandle;
    536     apHandle = reinterpret_cast<PVBGLR3GUESTPROPENUM>(
    537                                        RTMemAllocZ(sizeof(VBGLR3GUESTPROPENUM))
    538                                                      );
    539     if (NULL == apHandle.get())
     535    RTMemAutoPtr<VBGLR3GUESTPROPENUM, VbglR3GuestPropEnumFree> Handle;
     536    Handle = RTMemAllocZ(sizeof(VBGLR3GUESTPROPENUM));
     537    if (!Handle)
    540538        rc = VERR_NO_MEMORY;
    541539
     
    545543        cchPatterns += strlen(papszPatterns[i]) + 1;
    546544    /* Pack the pattern array */
    547     RTMemAutoPtr<char> pPatterns;
    548     pPatterns = reinterpret_cast<char *>(RTMemAlloc(cchPatterns));
    549     char *pchPatternsRaw = pPatterns.get();
     545    RTMemAutoPtr<char> Patterns;
     546    Patterns = reinterpret_cast<char *>(RTMemAlloc(cchPatterns));
     547    size_t iOffs = 0;
    550548    for (int i = 0; i < cPatterns; ++i)
    551549    {
    552550        size_t cb = strlen(papszPatterns[i]) + 1;
    553         memcpy(pchPatternsRaw, papszPatterns[i], cb);
    554         pchPatternsRaw += cb;
    555     }
    556     *pchPatternsRaw = '\0';
     551        memcpy(&Patterns[iOffs], papszPatterns[i], cb);
     552        iOffs += cb;
     553    }
     554    Patterns[iOffs] = '\0';
    557555
    558556    /* Randomly chosen initial size for the buffer to hold the enumeration
    559557     * information. */
    560558    uint32_t cchBuf = 4096;
    561     RTMemAutoPtr<char> pchBuf;
     559    RTMemAutoPtr<char> Buf;
    562560    /* In reading the guest property data we are racing against the host
    563561     * adding more of it, so loop a few times and retry on overflow. */
     
    566564        for (int i = 0; (i < 10) && !finish; ++i)
    567565        {
    568             if (!pchBuf.realloc<RTMemRealloc>(cchBuf))
     566            if (!Buf.realloc(cchBuf))
    569567                rc = VERR_NO_MEMORY;
    570568            if (RT_SUCCESS(rc) || (VERR_BUFFER_OVERFLOW == rc))
    571                 rc = VbglR3GuestPropEnumRaw(u32ClientId, pPatterns.get(),
    572                                             pchBuf.get(), cchBuf, &cchBuf);
     569                rc = VbglR3GuestPropEnumRaw(u32ClientId, Patterns.get(),
     570                                            Buf.get(), cchBuf, &cchBuf);
    573571            if (rc != VERR_BUFFER_OVERFLOW)
    574572                finish = true;
     
    581579    {
    582580        /* Transfer ownership of the buffer to the handle structure. */
    583         apHandle->pchBuf = pchBuf.release();
    584         apHandle->cchBuf = cchBuf;
    585     }
    586     if (RT_SUCCESS(rc))
    587         rc = VbglR3GuestPropEnumNext(apHandle.get(), ppszName, ppszValue,
     581        Handle->pchBuf = Buf.release();
     582        Handle->cchBuf = cchBuf;
     583    }
     584    if (RT_SUCCESS(rc))
     585        rc = VbglR3GuestPropEnumNext(Handle.get(), ppszName, ppszValue,
    588586                                     pu64Timestamp, ppszFlags);
    589587    if (RT_SUCCESS(rc) && (NULL == ppszName))
     
    592590    /* And transfer ownership of the handle to the caller. */
    593591    if (RT_SUCCESS(rc))
    594         *ppHandle = apHandle.release();
     592        *ppHandle = Handle.release();
    595593    return rc;
    596594}
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette