VirtualBox

Changeset 52934 in vbox for trunk/src/VBox/Main/src-client


Ignore:
Timestamp:
Oct 2, 2014 1:53:30 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
96372
Message:

Main: safearray cleanup, removed unnecessary SafeArray<->vector conversions

Location:
trunk/src/VBox/Main/src-client
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r52926 r52934  
    63366336void Console::i_onMousePointerShapeChange(bool fVisible, bool fAlpha,
    63376337                                          uint32_t xHot, uint32_t yHot,
    6338                                         uint32_t width, uint32_t height,
    6339                                         ComSafeArrayIn(BYTE,pShape))
     6338                                          uint32_t width, uint32_t height,
     6339                                          const uint8_t *pu8Shape,
     6340                                          uint32_t cbShape)
    63406341{
    63416342#if 0
     
    63486349    AssertComRCReturnVoid(autoCaller.rc());
    63496350
    6350     com::SafeArray<BYTE> aShape(ComSafeArrayInArg(pShape));
    63516351    if (!mMouse.isNull())
    63526352       mMouse->updateMousePointerShape(fVisible, fAlpha, xHot, yHot, width, height,
    6353                                        aShape.raw(), aShape.size());
    6354 
    6355     fireMousePointerShapeChangedEvent(mEventSource, fVisible, fAlpha, xHot, yHot, width, height, ComSafeArrayInArg(pShape));
     6353                                       pu8Shape, cbShape);
     6354
     6355    com::SafeArray<BYTE> shape(cbShape);
     6356    if (pu8Shape)
     6357        memcpy(shape.raw(), pu8Shape, cbShape);
     6358    fireMousePointerShapeChangedEvent(mEventSource, fVisible, fAlpha, xHot, yHot, width, height, ComSafeArrayAsInParam(shape));
    63566359
    63576360#if 0
  • trunk/src/VBox/Main/src-client/DisplayImpl.cpp

    r52769 r52934  
    37983798    Display *pThis = pDrv->pDisplay;
    37993799
    3800     size_t cbShapeSize = 0;
    3801 
     3800    uint32_t cbShape = 0;
    38023801    if (pvShape)
    38033802    {
    3804         cbShapeSize = (cx + 7) / 8 * cy; /* size of the AND mask */
    3805         cbShapeSize = ((cbShapeSize + 3) & ~3) + cx * 4 * cy; /* + gap + size of the XOR mask */
    3806     }
    3807     com::SafeArray<BYTE> shapeData(cbShapeSize);
    3808 
    3809     if (pvShape)
    3810         ::memcpy(shapeData.raw(), pvShape, cbShapeSize);
     3803        cbShape = (cx + 7) / 8 * cy; /* size of the AND mask */
     3804        cbShape = ((cbShape + 3) & ~3) + cx * 4 * cy; /* + gap + size of the XOR mask */
     3805    }
    38113806
    38123807    /* Tell the console about it */
    38133808    pDrv->pDisplay->mParent->i_onMousePointerShapeChange(fVisible, fAlpha,
    3814                                                          xHot, yHot, cx, cy, ComSafeArrayAsInParam(shapeData));
     3809                                                         xHot, yHot, cx, cy, (uint8_t *)pvShape, cbShape);
    38153810
    38163811    return VINF_SUCCESS;
  • trunk/src/VBox/Main/src-client/GuestFileImpl.cpp

    r50727 r52934  
    12731273        return setError(E_INVALIDARG, tr("The size to read is zero"));
    12741274
    1275     com::SafeArray<BYTE> data((size_t)aToRead);
    1276     Assert(data.size() >= aToRead);
     1275    aData.resize(aToRead);
    12771276
    12781277    HRESULT hr = S_OK;
     
    12801279    uint32_t cbRead;
    12811280    int vrc = i_readData(aToRead, aTimeoutMS,
    1282                          data.raw(), aToRead, &cbRead);
    1283 
    1284     if (RT_SUCCESS(vrc))
    1285     {
    1286         if (data.size() != cbRead)
    1287             data.resize(cbRead);
    1288         aData.resize(data.size());
    1289         for(size_t i = 0; i < data.size(); ++i)
    1290             aData[i] = data[i];
     1281                         &aData.front(), aToRead, &cbRead);
     1282
     1283    if (RT_SUCCESS(vrc))
     1284    {
     1285        if (aData.size() != cbRead)
     1286            aData.resize(cbRead);
    12911287    }
    12921288    else
    12931289    {
     1290        aData.resize(0);
     1291
    12941292        switch (vrc)
    12951293        {
     
    13151313        return setError(E_INVALIDARG, tr("The size to read is zero"));
    13161314
    1317     com::SafeArray<BYTE> data((size_t)aToRead);
    1318     Assert(data.size() >= aToRead);
     1315    aData.resize(aToRead);
    13191316
    13201317    HRESULT hr = S_OK;
     
    13221319    size_t cbRead;
    13231320    int vrc = i_readDataAt(aOffset, aToRead, aTimeoutMS,
    1324                            data.raw(), aToRead, &cbRead);
    1325     if (RT_SUCCESS(vrc))
    1326     {
    1327         if (data.size() != cbRead)
    1328             data.resize(cbRead);
    1329         aData.resize(data.size());
    1330         for(size_t i = 0; i < data.size(); ++i)
    1331             aData[i] = data[i];
     1321                           &aData.front(), aToRead, &cbRead);
     1322    if (RT_SUCCESS(vrc))
     1323    {
     1324        if (aData.size() != cbRead)
     1325            aData.resize(cbRead);
    13321326    }
    13331327    else
    13341328    {
     1329        aData.resize(0);
     1330
    13351331        switch (vrc)
    13361332        {
     
    14101406    HRESULT hr = S_OK;
    14111407
    1412     com::SafeArray<BYTE> data(aData);
    1413     int vrc = i_writeData(aTimeoutMS, data.raw(), (uint32_t)data.size(),
     1408    uint32_t cbData = (uint32_t)aData.size();
     1409    void *pvData = cbData > 0? (void *)&aData.front(): NULL;
     1410    int vrc = i_writeData(aTimeoutMS, pvData, cbData,
    14141411                          (uint32_t*)aWritten);
    14151412    if (RT_FAILURE(vrc))
     
    14201417                hr = setError(VBOX_E_IPRT_ERROR,
    14211418                              tr("Writing %zubytes to file \"%s\" failed: %Rrc"),
    1422                               data.size(), mData.mOpenInfo.mFileName.c_str(), vrc);
     1419                              aData.size(), mData.mOpenInfo.mFileName.c_str(), vrc);
    14231420                break;
    14241421        }
     
    14401437    HRESULT hr = S_OK;
    14411438
    1442     com::SafeArray<BYTE> data(aData);
    1443     int vrc = i_writeData(aTimeoutMS, data.raw(), (uint32_t)data.size(),
     1439    uint32_t cbData = (uint32_t)aData.size();
     1440    void *pvData = cbData > 0? (void *)&aData.front(): NULL;
     1441    int vrc = i_writeData(aTimeoutMS, pvData, cbData,
    14441442                          (uint32_t*)aWritten);
    14451443    if (RT_FAILURE(vrc))
     
    14501448                hr = setError(VBOX_E_IPRT_ERROR,
    14511449                              tr("Writing %zubytes to file \"%s\" (at offset %RU64) failed: %Rrc"),
    1452                               data.size(), mData.mOpenInfo.mFileName.c_str(), aOffset, vrc);
     1450                              aData.size(), mData.mOpenInfo.mFileName.c_str(), aOffset, vrc);
    14531451                break;
    14541452        }
  • trunk/src/VBox/Main/src-client/GuestProcessImpl.cpp

    r50899 r52934  
    292292
    293293    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    294 
    295     com::SafeArray<BSTR> collection(mData.mProcess.mArguments.size());
    296     size_t s = 0;
    297     for (ProcessArguments::const_iterator it = mData.mProcess.mArguments.begin();
    298          it != mData.mProcess.mArguments.end();
    299          it++, s++)
    300          aArguments[s] = (*it);
    301 
     294    aArguments = mData.mProcess.mArguments;
    302295    return S_OK;
    303296#endif /* VBOX_WITH_GUEST_CONTROL */
     
    312305
    313306    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    314 
    315     com::SafeArray<BSTR> arguments(mData.mProcess.mEnvironment.Size());
    316     for (size_t i = 0; i < arguments.size(); i++)
    317         aEnvironment[i] = mData.mProcess.mEnvironment.Get(i);
    318 
     307    mData.mProcess.mEnvironment.CopyTo(aEnvironment);
    319308    return S_OK;
    320309#endif /* VBOX_WITH_GUEST_CONTROL */
     
    17511740        return setError(E_INVALIDARG, tr("The size to read is zero"));
    17521741
    1753     com::SafeArray<BYTE> data((size_t)aToRead);
    1754     Assert(data.size() >= aToRead);
     1742    aData.resize(aToRead);
    17551743
    17561744    HRESULT hr = S_OK;
    17571745
    17581746    uint32_t cbRead; int guestRc;
    1759     int vrc = i_readData(aHandle, aToRead, aTimeoutMS, data.raw(), aToRead, &cbRead, &guestRc);
     1747    int vrc = i_readData(aHandle, aToRead, aTimeoutMS, &aData.front(), aToRead, &cbRead, &guestRc);
    17601748    if (RT_SUCCESS(vrc))
    17611749    {
    1762         if (data.size() != cbRead)
    1763             data.resize(cbRead);
    1764         for(size_t i = 0; i < data.size(); ++i)
    1765             aData[i] = data[i];
     1750        if (aData.size() != cbRead)
     1751            aData.resize(cbRead);
    17661752    }
    17671753    else
    17681754    {
     1755        aData.resize(0);
     1756
    17691757        switch (vrc)
    17701758        {
     
    19031891
    19041892    HRESULT hr = S_OK;
    1905     com::SafeArray<BYTE> data;
    1906     for(size_t i = 0; i < aData.size(); ++i)
    1907         data[i] = aData[i];
     1893
    19081894    uint32_t cbWritten; int guestRc;
    1909     int vrc = i_writeData(aHandle, aFlags, data.raw(), data.size(), aTimeoutMS, &cbWritten, &guestRc);
     1895    uint32_t cbData = (uint32_t)aData.size();
     1896    void *pvData = cbData > 0? (void *)&aData.front(): NULL;
     1897    int vrc = i_writeData(aHandle, aFlags, pvData, cbData, aTimeoutMS, &cbWritten, &guestRc);
    19101898    if (RT_FAILURE(vrc))
    19111899    {
  • trunk/src/VBox/Main/src-client/KeyboardImpl.cpp

    r52924 r52934  
    175175                               ULONG *aCodesStored)
    176176{
    177     com::SafeArray<LONG> keys;
    178     keys.resize(aScancodes.size());
    179     for (size_t i = 0; i < aScancodes.size(); ++i)
    180         keys[i] = aScancodes[i];
    181 
    182177    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    183178
     
    213208    if (aCodesStored)
    214209        *aCodesStored = sent;
     210
     211    com::SafeArray<LONG> keys(aScancodes.size());
     212    for (size_t i = 0; i < aScancodes.size(); ++i)
     213        keys[i] = aScancodes[i];
    215214
    216215    VBoxEventDesc evDesc;
  • trunk/src/VBox/Main/src-client/MouseImpl.cpp

    r52921 r52934  
    861861                                  ULONG aScanTime)
    862862{
    863     com::SafeArray <LONG64> arrayContacts(aContacts);
    864 
    865863    LogRel3(("%s: aCount %d(actual %d), aScanTime %u\n",
    866              __FUNCTION__, aCount, arrayContacts.size(), aScanTime));
     864             __FUNCTION__, aCount, aContacts.size(), aScanTime));
    867865
    868866    HRESULT rc = S_OK;
    869867
    870     if ((LONG)arrayContacts.size() >= aCount)
    871     {
    872         LONG64* paContacts = arrayContacts.raw();
     868    if ((LONG)aContacts.size() >= aCount)
     869    {
     870        const LONG64 *paContacts = aCount > 0? &aContacts.front(): NULL;
    873871
    874872        rc = i_putEventMultiTouch(aCount, paContacts, aScanTime);
     
    907905/* Used by PutEventMultiTouch and PutEventMultiTouchString. */
    908906HRESULT Mouse::i_putEventMultiTouch(LONG aCount,
    909                                     LONG64 *paContacts,
     907                                    const LONG64 *paContacts,
    910908                                    ULONG aScanTime)
    911909{
  • trunk/src/VBox/Main/src-client/VMMDevInterface.cpp

    r52652 r52934  
    346346
    347347    /* tell the console about it */
    348     size_t cbShapeSize = 0;
    349 
     348    uint32_t cbShape = 0;
    350349    if (pShape)
    351350    {
    352         cbShapeSize = (width + 7) / 8 * height; /* size of the AND mask */
    353         cbShapeSize = ((cbShapeSize + 3) & ~3) + width * 4 * height; /* + gap + size of the XOR mask */
    354     }
    355     com::SafeArray<BYTE> shapeData(cbShapeSize);
    356     if (pShape)
    357         ::memcpy(shapeData.raw(), pShape, cbShapeSize);
    358     pConsole->i_onMousePointerShapeChange(fVisible, fAlpha, xHot, yHot, width, height, ComSafeArrayAsInParam(shapeData));
     351        cbShape = (width + 7) / 8 * height; /* size of the AND mask */
     352        cbShape = ((cbShape + 3) & ~3) + width * 4 * height; /* + gap + size of the XOR mask */
     353    }
     354    pConsole->i_onMousePointerShapeChange(fVisible, fAlpha, xHot, yHot, width, height, (uint8_t *)pShape, cbShape);
    359355}
    360356
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