Skip to content

Commit

Permalink
cppcheck performance fixes in win32/
Browse files Browse the repository at this point in the history
  • Loading branch information
tobbi committed Feb 5, 2015
1 parent d12581d commit 6d17c3a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
14 changes: 10 additions & 4 deletions xbmc/win32/WIN32Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -772,8 +772,8 @@ bool CWIN32Util::EjectDrive(const char cDriveLetter)
char VetoName[MAX_PATH];
bool bSuccess = false;

res = CM_Get_Parent(&DevInst, DevInst, 0); // disk's parent, e.g. the USB bridge, the SATA controller....
res = CM_Get_DevNode_Status(&Status, &ProblemNumber, DevInst, 0);
CM_Get_Parent(&DevInst, DevInst, 0); // disk's parent, e.g. the USB bridge, the SATA controller....
CM_Get_DevNode_Status(&Status, &ProblemNumber, DevInst, 0);

for(int i=0;i<3;i++)
{
Expand Down Expand Up @@ -1387,8 +1387,14 @@ LONG CWIN32Util::UtilRegGetValue( const HKEY hKey, const char *const pcKey, DWOR
{
if (ppcBuffer)
{
char *pcValue=*ppcBuffer;
if (!pcValue || !pdwSizeBuff || dwSize +dwSizeAdd > *pdwSizeBuff) pcValue= (char*)realloc(pcValue, dwSize +dwSizeAdd);
char *pcValue=*ppcBuffer, *pcValueTmp;
if (!pcValue || !pdwSizeBuff || dwSize +dwSizeAdd > *pdwSizeBuff) {
pcValueTmp = (char*)realloc(pcValue, dwSize +dwSizeAdd);
if(pcValueTmp != NULL)
{
pcValue = pcValueTmp;
}
}
lRet= RegQueryValueEx(hKey,pcKey,NULL,NULL,(LPBYTE)pcValue,&dwSize);

if ( lRet == ERROR_SUCCESS || *ppcBuffer ) *ppcBuffer= pcValue;
Expand Down
3 changes: 1 addition & 2 deletions xbmc/win32/XBMC_PC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,9 @@ INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR commandLine, INT )
}
#endif

HRESULT hr = E_FAIL;
IMMDeviceEnumerator *pEnumerator = NULL;
CMMNotificationClient cMMNC;
hr = CoCreateInstance(CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, IID_IMMDeviceEnumerator, (void**)&pEnumerator);
HRESULT hr = CoCreateInstance(CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, IID_IMMDeviceEnumerator, (void**)&pEnumerator);
if(SUCCEEDED(hr))
{
pEnumerator->RegisterEndpointNotificationCallback(&cMMNC);
Expand Down

0 comments on commit 6d17c3a

Please sign in to comment.