VirtualBox

Changeset 44735 in vbox for trunk/src/VBox/Additions/WINNT


Ignore:
Timestamp:
Feb 18, 2013 2:01:33 PM (12 years ago)
Author:
vboxsync
Message:

WINNT/VBoxTray.cpp: memory leak fix, code fixes as per VBox standard.

Location:
trunk/src/VBox/Additions/WINNT/VBoxTray
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDispIf.cpp

    r44732 r44735  
    13231323          */
    13241324        if (OSinfo.dwMajorVersion >= 6 && OSinfo.dwMinorVersion >= 1)
    1325             winEr = vboxDispIfWddmResizeDisplay(pIf,iChangedMode, paDisplayDevices, paDeviceModes, cDevModes);
     1325            winEr = vboxDispIfWddmResizeDisplay(pIf, iChangedMode, paDisplayDevices, paDeviceModes, cDevModes);
    13261326        else
    13271327            winEr = vboxDispIfWddmValidateFixResize(pIf, paDisplayDevices, paDeviceModes, cDevModes);
     
    13581358    DISPLAYCONFIG_PATH_INFO *pPathInfoArray;
    13591359    DISPLAYCONFIG_MODE_INFO *pModeInfoArray;
    1360     UINT NumPathArrayElements = 0;
    1361     UINT NumModeInfoArrayElements = 0;
     1360    UINT numPathArrayElements = 0;
     1361    UINT numModeInfoArrayElements = 0;
    13621362    ULONG dwStatus;
    13631363
    1364     dwStatus = gCtx.pfnGetDisplayConfigBufferSizes(fEnabled ? QDC_ALL_PATHS : QDC_ONLY_ACTIVE_PATHS,&NumPathArrayElements,&NumModeInfoArrayElements);
     1364    dwStatus = gCtx.pfnGetDisplayConfigBufferSizes(fEnabled ? QDC_ALL_PATHS : QDC_ONLY_ACTIVE_PATHS, &numPathArrayElements, &numModeInfoArrayElements);
    13651365    if (dwStatus != ERROR_SUCCESS)
    13661366    {
     
    13681368        return dwStatus;
    13691369    }
    1370     pPathInfoArray = (DISPLAYCONFIG_PATH_INFO *)malloc(NumPathArrayElements * sizeof(DISPLAYCONFIG_PATH_INFO));
    1371     pModeInfoArray = (DISPLAYCONFIG_MODE_INFO *)malloc(NumModeInfoArrayElements * sizeof(DISPLAYCONFIG_MODE_INFO));
    1372     if (!pPathInfoArray || !pModeInfoArray )
    1373     {
     1370    pPathInfoArray = (DISPLAYCONFIG_PATH_INFO *)malloc(numPathArrayElements * sizeof(DISPLAYCONFIG_PATH_INFO));
     1371     if (!pPathInfoArray)
    13741372        return ERROR_OUTOFMEMORY;
    1375     }
    1376     dwStatus = gCtx.pfnQueryDisplayConfig(fEnabled ? QDC_ALL_PATHS : QDC_ONLY_ACTIVE_PATHS,&NumPathArrayElements, pPathInfoArray,&NumModeInfoArrayElements, pModeInfoArray,NULL);
     1373    pModeInfoArray = (DISPLAYCONFIG_MODE_INFO *)malloc(numModeInfoArrayElements * sizeof(DISPLAYCONFIG_MODE_INFO));
     1374    if (!pModeInfoArray )
     1375    {
     1376        if (pPathInfoArray)
     1377        {
     1378            free(pPathInfoArray);
     1379        }
     1380        return ERROR_OUTOFMEMORY;
     1381    }
     1382    dwStatus = gCtx.pfnQueryDisplayConfig(fEnabled ? QDC_ALL_PATHS : QDC_ONLY_ACTIVE_PATHS, &numPathArrayElements, pPathInfoArray,&numModeInfoArrayElements, pModeInfoArray, NULL);
    13771383    if (dwStatus != ERROR_SUCCESS)
    13781384    {
     
    13841390        return dwStatus;
    13851391    }
    1386     for (unsigned int i=0; i < NumPathArrayElements; ++i)
     1392    for (unsigned int i=0; i < numPathArrayElements; ++i)
    13871393    {
    13881394        LogRel(("Sourceid= %d and targetid = %d\n", pPathInfoArray[i].sourceInfo.id, pPathInfoArray[i].targetInfo.id));
     
    14031409        }
    14041410    }
    1405     dwStatus = gCtx.pfnSetDisplayConfig(NumPathArrayElements, pPathInfoArray, NumModeInfoArrayElements, pModeInfoArray, (SDC_APPLY | SDC_SAVE_TO_DATABASE| SDC_ALLOW_CHANGES | SDC_USE_SUPPLIED_DISPLAY_CONFIG));
     1411    dwStatus = gCtx.pfnSetDisplayConfig(numPathArrayElements, pPathInfoArray, numModeInfoArrayElements, pModeInfoArray, (SDC_APPLY | SDC_SAVE_TO_DATABASE| SDC_ALLOW_CHANGES | SDC_USE_SUPPLIED_DISPLAY_CONFIG));
    14061412    if (dwStatus != ERROR_SUCCESS)
    14071413    {
     
    14241430    DISPLAYCONFIG_PATH_INFO *pPathInfoArray;
    14251431    DISPLAYCONFIG_MODE_INFO *pModeInfoArray;
    1426     UINT NumPathArrayElements = 0;
    1427     UINT NumModeInfoArrayElements = 0;
     1432    UINT numPathArrayElements = 0;
     1433    UINT numModeInfoArrayElements = 0;
    14281434    ULONG dwStatus;
    14291435
    1430     dwStatus = gCtx.pfnGetDisplayConfigBufferSizes(QDC_ONLY_ACTIVE_PATHS,&NumPathArrayElements,&NumModeInfoArrayElements);
     1436    dwStatus = gCtx.pfnGetDisplayConfigBufferSizes(QDC_ONLY_ACTIVE_PATHS, &numPathArrayElements, &numModeInfoArrayElements);
    14311437    if (dwStatus != ERROR_SUCCESS)
    14321438    {
     
    14341440        return dwStatus;
    14351441    }
    1436     pPathInfoArray = (DISPLAYCONFIG_PATH_INFO *)malloc(NumPathArrayElements * sizeof(DISPLAYCONFIG_PATH_INFO));
    1437     pModeInfoArray = (DISPLAYCONFIG_MODE_INFO *)malloc(NumModeInfoArrayElements * sizeof(DISPLAYCONFIG_MODE_INFO));
    1438     if (!pPathInfoArray || !pModeInfoArray )
    1439     {
     1442    pPathInfoArray = (DISPLAYCONFIG_PATH_INFO *)malloc(numPathArrayElements * sizeof(DISPLAYCONFIG_PATH_INFO));
     1443    if (!pPathInfoArray)
    14401444        return ERROR_OUTOFMEMORY;
    1441     }
    1442     dwStatus = gCtx.pfnQueryDisplayConfig( QDC_ONLY_ACTIVE_PATHS,&NumPathArrayElements, pPathInfoArray,&NumModeInfoArrayElements, pModeInfoArray,NULL);
     1445    pModeInfoArray = (DISPLAYCONFIG_MODE_INFO *)malloc(numModeInfoArrayElements * sizeof(DISPLAYCONFIG_MODE_INFO));
     1446    if (!pModeInfoArray )
     1447    {
     1448        if (pPathInfoArray)
     1449        {
     1450            free(pPathInfoArray);
     1451        }
     1452        return ERROR_OUTOFMEMORY;
     1453    }
     1454    dwStatus = gCtx.pfnQueryDisplayConfig( QDC_ONLY_ACTIVE_PATHS, &numPathArrayElements, pPathInfoArray,&numModeInfoArrayElements, pModeInfoArray, NULL);
    14431455    if (dwStatus != ERROR_SUCCESS)
    14441456    {
     
    14501462        return dwStatus;
    14511463     }
    1452     for (unsigned int i=0; i < NumPathArrayElements; ++i)
     1464    for (unsigned int i=0; i < numPathArrayElements; ++i)
    14531465    {
    14541466        LogRel(("Sourceid= %d and targetid = %d\n", pPathInfoArray[i].sourceInfo.id, pPathInfoArray[i].targetInfo.id));
     
    14641476        }
    14651477    }
    1466     dwStatus = gCtx.pfnSetDisplayConfig(NumPathArrayElements, pPathInfoArray, NumModeInfoArrayElements, pModeInfoArray,(SDC_APPLY | SDC_SAVE_TO_DATABASE| SDC_ALLOW_CHANGES | SDC_USE_SUPPLIED_DISPLAY_CONFIG));
    1467     if (dwStatus != ERROR_SUCCESS) {
     1478    dwStatus = gCtx.pfnSetDisplayConfig(numPathArrayElements, pPathInfoArray, numModeInfoArrayElements, pModeInfoArray,(SDC_APPLY | SDC_SAVE_TO_DATABASE| SDC_ALLOW_CHANGES | SDC_USE_SUPPLIED_DISPLAY_CONFIG));
     1479    if (dwStatus != ERROR_SUCCESS)
     1480    {
    14681481        if (pPathInfoArray)
    14691482            free(pPathInfoArray);
  • trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDisplay.cpp

    r44648 r44735  
    213213}
    214214
    215 static DWORD EnableAndResizeDispDev(DEVMODE *paDeviceModes, DISPLAY_DEVICE *paDisplayDevices, DWORD totalDispNum, ULONG Id, DWORD aWidth, DWORD aHeight,
     215static DWORD EnableAndResizeDispDev(DEVMODE *paDeviceModes, DISPLAY_DEVICE *paDisplayDevices, DWORD totalDispNum, UINT Id, DWORD aWidth, DWORD aHeight,
    216216                                    DWORD aBitsPerPixel, DWORD aPosX, DWORD aPosY, BOOL fEnabled, BOOL fExtDispSup, VBOXDISPLAYCONTEXT *pCtx)
    217217{
     
    310310
    311311/* Returns TRUE to try again. */
    312 static BOOL ResizeDisplayDevice(ULONG Id, DWORD Width, DWORD Height, DWORD BitsPerPixel,
     312static BOOL ResizeDisplayDevice(UINT Id, DWORD Width, DWORD Height, DWORD BitsPerPixel,
    313313                                BOOL fEnabled, DWORD dwNewPosX, DWORD dwNewPosY,
    314314                                VBOXDISPLAYCONTEXT *pCtx, BOOL fExtDispSup)
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