VirtualBox

Ignore:
Timestamp:
Jul 23, 2008 1:06:20 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
33614
Message:

Additions/common: small adjustment in guest property reading code

File:
1 edited

Legend:

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

    r10825 r10829  
    884884    int rc = VINF_SUCCESS;
    885885
    886     /* We leave a bit of space here in case the maximum values are raised. */
    887     uint32_t cbBuf = MAX_VALUE_LEN + MAX_FLAGS_LEN + 1024;
    888     void *pvBuf = RTMemAlloc(cbBuf);
    889     if (NULL == pvBuf)
    890     {
    891         rc = VERR_NO_MEMORY;
    892         VBoxControlError("Out of memory\n");
    893     }
    894     if (RT_SUCCESS(rc))
    895     {
    896         rc = VbglR3GuestPropConnect(&u32ClientId);
    897         if (!RT_SUCCESS(rc))
    898             VBoxControlError("Failed to connect to the guest property service, error %Rrc\n", rc);
    899     }
     886    rc = VbglR3GuestPropConnect(&u32ClientId);
     887    if (!RT_SUCCESS(rc))
     888        VBoxControlError("Failed to connect to the guest property service, error %Rrc\n", rc);
    900889
    901890/*
     
    913902         * enough with buffer space. */
    914903        bool finish = false;
    915         for (int i = 0; (i < 10) && !finish; ++i)
    916         {
    917             rc = VbglR3GuestPropRead(u32ClientId, pszName, pvBuf, cbBuf,
    918                                      &pszValue, &u64Timestamp, &pszFlags,
    919                                      &cbBuf);
     904        /* We leave a bit of space here in case the maximum values are raised. */
     905        void *pvBuf = NULL;
     906        uint32_t cbBuf = MAX_VALUE_LEN + MAX_FLAGS_LEN + 1024;
     907        for (unsigned i = 0; (i < 10) && !finish; ++i)
     908        {
     909            pvBuf = RTMemRealloc(pvBuf, cbBuf);
     910            if (NULL == pvBuf)
     911            {
     912                rc = VERR_NO_MEMORY;
     913                VBoxControlError("Out of memory\n");
     914            }
     915            else
     916                rc = VbglR3GuestPropRead(u32ClientId, pszName, pvBuf, cbBuf,
     917                                         &pszValue, &u64Timestamp, &pszFlags,
     918                                         &cbBuf);
    920919            if (VERR_BUFFER_OVERFLOW == rc)
    921             {
    922                 pvBuf = RTMemRealloc(pvBuf, cbBuf);
    923                 if (NULL == pvBuf)
    924                     rc = VERR_NO_MEMORY;
    925             }
    926             if (rc != VERR_BUFFER_OVERFLOW)
     920                /* Leave a bit of extra space to be safe */
     921                cbBuf += 1024;
     922            else
    927923                finish = true;
    928924        }
Note: See TracChangeset for help on using the changeset viewer.

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