Commit 43f01a2f authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

winmm: Use CRT allocation functions.

parent 38111eb3
......@@ -286,7 +286,7 @@ LPWINE_DRIVER DRIVER_TryOpenDriver32(LPCWSTR fn, LPARAM lParam2)
if (*ptr == '\0') ptr = NULL;
}
lpDrv = HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_DRIVER));
lpDrv = malloc(sizeof(WINE_DRIVER));
if (lpDrv == NULL) {cause = "OOM"; goto exit;}
if ((hModule = LoadLibraryW(fn)) == 0) {cause = "Not a 32 bit lib"; goto exit;}
......@@ -329,7 +329,7 @@ LPWINE_DRIVER DRIVER_TryOpenDriver32(LPCWSTR fn, LPARAM lParam2)
return lpDrv;
exit:
FreeLibrary(hModule);
HeapFree(GetProcessHeap(), 0, lpDrv);
free(lpDrv);
TRACE("Unable to load 32 bit module %s: %s\n", debugstr_w(fn), cause);
return NULL;
}
......@@ -351,7 +351,7 @@ HDRVR WINAPI OpenDriverA(LPCSTR lpDriverName, LPCSTR lpSectionName, LPARAM lPara
if (lpDriverName)
{
len = MultiByteToWideChar( CP_ACP, 0, lpDriverName, -1, NULL, 0 );
dn = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
dn = malloc( len * sizeof(WCHAR) );
if (!dn) goto done;
MultiByteToWideChar( CP_ACP, 0, lpDriverName, -1, dn, len );
}
......@@ -359,7 +359,7 @@ HDRVR WINAPI OpenDriverA(LPCSTR lpDriverName, LPCSTR lpSectionName, LPARAM lPara
if (lpSectionName)
{
len = MultiByteToWideChar( CP_ACP, 0, lpSectionName, -1, NULL, 0 );
sn = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
sn = malloc( len * sizeof(WCHAR) );
if (!sn) goto done;
MultiByteToWideChar( CP_ACP, 0, lpSectionName, -1, sn, len );
}
......@@ -367,8 +367,8 @@ HDRVR WINAPI OpenDriverA(LPCSTR lpDriverName, LPCSTR lpSectionName, LPARAM lPara
ret = OpenDriver(dn, sn, lParam);
done:
HeapFree(GetProcessHeap(), 0, dn);
HeapFree(GetProcessHeap(), 0, sn);
free(dn);
free(sn);
return ret;
}
......@@ -439,11 +439,11 @@ LRESULT WINAPI CloseDriver(HDRVR hDrvr, LPARAM lParam1, LPARAM lParam2)
DRIVER_SendMessage(lpDrv0, DRV_CLOSE, 0, 0);
DRIVER_RemoveFromList(lpDrv0);
FreeLibrary(lpDrv0->hModule);
HeapFree(GetProcessHeap(), 0, lpDrv0);
free(lpDrv0);
}
FreeLibrary(lpDrv->hModule);
HeapFree(GetProcessHeap(), 0, lpDrv);
free(lpDrv);
ret = TRUE;
}
else
......
......@@ -137,7 +137,7 @@ LPWINE_MLD MMDRV_Alloc(UINT size, UINT type, LPHANDLE hndl, DWORD* dwFlags,
TRACE("(%d, %04x, %p, %p, %p, %p)\n",
size, type, hndl, dwFlags, dwCallback, dwInstance);
mld = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
mld = calloc(1, size);
if (!mld) return NULL;
/* find an empty slot in MM_MLDrvs table */
......@@ -146,7 +146,7 @@ LPWINE_MLD MMDRV_Alloc(UINT size, UINT type, LPHANDLE hndl, DWORD* dwFlags,
if (i == ARRAY_SIZE(MM_MLDrvs)) {
/* the MM_MLDrvs table could be made growable in the future if needed */
ERR("Too many open drivers\n");
HeapFree(GetProcessHeap(), 0, mld);
free(mld);
return NULL;
}
MM_MLDrvs[i] = mld;
......@@ -179,7 +179,7 @@ void MMDRV_Free(HANDLE hndl, LPWINE_MLD mld)
UINT_PTR idx = (UINT_PTR)hndl & ~0x8000;
if (idx < ARRAY_SIZE(MM_MLDrvs)) {
MM_MLDrvs[idx] = NULL;
HeapFree(GetProcessHeap(), 0, mld);
free(mld);
return;
}
}
......@@ -372,14 +372,9 @@ static BOOL MMDRV_InitPerType(LPWINE_MM_DRIVER lpDrv, UINT type, UINT wMsg)
part->nIDMin, part->nIDMax, llTypes[type].wMaxId,
lpDrv->drvname, llTypes[type].typestr);
/* realloc translation table */
if (llTypes[type].lpMlds) {
mem = llTypes[type].lpMlds - 1;
mem = HeapReAlloc(GetProcessHeap(), 0, mem, sizeof(WINE_MLD) * (llTypes[type].wMaxId + 1));
llTypes[type].lpMlds = mem + 1;
} else {
mem = HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_MLD) * (llTypes[type].wMaxId + 1));
llTypes[type].lpMlds = mem + 1;
}
mem = llTypes[type].lpMlds ? llTypes[type].lpMlds - 1 : NULL;
mem = realloc(mem, sizeof(WINE_MLD) * (llTypes[type].wMaxId + 1));
llTypes[type].lpMlds = mem + 1;
/* re-build the translation table */
if (lpDrv->bIsMapper) {
......@@ -463,7 +458,7 @@ static BOOL MMDRV_Install(LPCSTR drvRegName, LPCSTR drvFileName, BOOL bIsMapper)
* I don't have any clue for PE drvs
*/
lpDrv->bIsMapper = bIsMapper;
lpDrv->drvname = strcpy(HeapAlloc(GetProcessHeap(), 0, strlen(drvRegName) + 1), drvRegName);
lpDrv->drvname = strdup(drvRegName);
/* Finish init and get the count of the devices */
i = 0;
......@@ -476,7 +471,7 @@ static BOOL MMDRV_Install(LPCSTR drvRegName, LPCSTR drvFileName, BOOL bIsMapper)
/* if all those func calls return FALSE, then the driver must be unloaded */
if (!i) {
CloseDriver(lpDrv->hDriver, 0, 0);
HeapFree(GetProcessHeap(), 0, lpDrv->drvname);
free(lpDrv->drvname);
WARN("Driver initialization failed\n");
return FALSE;
}
......@@ -535,12 +530,12 @@ static void MMDRV_Init(void)
size = WideCharToMultiByte(CP_ACP, 0, pv.pwszVal, -1,
NULL, 0, NULL, NULL);
drvA = HeapAlloc(GetProcessHeap(), 0, size);
drvA = malloc(size);
WideCharToMultiByte(CP_ACP, 0, pv.pwszVal, -1, drvA, size, NULL, NULL);
MMDRV_Install(drvA, drvA, FALSE);
HeapFree(GetProcessHeap(), 0, drvA);
free(drvA);
PropVariantClear(&pv);
MMDRV_Install("wavemapper", "msacm32.drv", TRUE);
......@@ -609,15 +604,15 @@ void MMDRV_Exit(void)
CloseDriver(MMDrvs[i].hDriver, 0, 0);
}
if (llTypes[MMDRV_AUX].lpMlds)
HeapFree(GetProcessHeap(), 0, llTypes[MMDRV_AUX].lpMlds - 1);
free(llTypes[MMDRV_AUX].lpMlds - 1);
if (llTypes[MMDRV_MIXER].lpMlds)
HeapFree(GetProcessHeap(), 0, llTypes[MMDRV_MIXER].lpMlds - 1);
free(llTypes[MMDRV_MIXER].lpMlds - 1);
if (llTypes[MMDRV_MIDIIN].lpMlds)
HeapFree(GetProcessHeap(), 0, llTypes[MMDRV_MIDIIN].lpMlds - 1);
free(llTypes[MMDRV_MIDIIN].lpMlds - 1);
if (llTypes[MMDRV_MIDIOUT].lpMlds)
HeapFree(GetProcessHeap(), 0, llTypes[MMDRV_MIDIOUT].lpMlds - 1);
free(llTypes[MMDRV_MIDIOUT].lpMlds - 1);
if (llTypes[MMDRV_WAVEIN].lpMlds)
HeapFree(GetProcessHeap(), 0, llTypes[MMDRV_WAVEIN].lpMlds - 1);
free(llTypes[MMDRV_WAVEIN].lpMlds - 1);
if (llTypes[MMDRV_WAVEOUT].lpMlds)
HeapFree(GetProcessHeap(), 0, llTypes[MMDRV_WAVEOUT].lpMlds - 1);
free(llTypes[MMDRV_WAVEOUT].lpMlds - 1);
}
......@@ -72,13 +72,8 @@ static UINT MCI_SetCommandTable(HGLOBAL hMem, UINT uDevType);
/* dup a string and uppercase it */
static inline LPWSTR str_dup_upper( LPCWSTR str )
{
INT len = (lstrlenW(str) + 1) * sizeof(WCHAR);
LPWSTR p = HeapAlloc( GetProcessHeap(), 0, len );
if (p)
{
memcpy( p, str, len );
CharUpperW( p );
}
WCHAR *p = wcsdup( str );
if (p) CharUpperW( p );
return p;
}
......@@ -204,7 +199,7 @@ static LPWSTR MCI_strdupAtoW( LPCSTR str )
if (!str) return NULL;
len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
ret = malloc( len * sizeof(WCHAR) );
if (ret) MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
return ret;
}
......@@ -252,7 +247,7 @@ static int MCI_MapMsgAtoW(UINT msg, DWORD_PTR dwParam1, DWORD_PTR *dwParam2)
MCI_ANIM_OPEN_PARMSW *mci_openW;
DWORD_PTR *ptr;
ptr = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD_PTR) + sizeof(*mci_openW));
ptr = malloc(sizeof(DWORD_PTR) + sizeof(*mci_openW));
if (!ptr) return -1;
*ptr++ = *dwParam2; /* save the previous pointer */
......@@ -291,7 +286,7 @@ static int MCI_MapMsgAtoW(UINT msg, DWORD_PTR dwParam1, DWORD_PTR *dwParam2)
MCI_ANIM_WINDOW_PARMSA *mci_windowA = (MCI_ANIM_WINDOW_PARMSA *)*dwParam2;
MCI_ANIM_WINDOW_PARMSW *mci_windowW;
mci_windowW = HeapAlloc(GetProcessHeap(), 0, sizeof(*mci_windowW));
mci_windowW = malloc(sizeof(*mci_windowW));
if (!mci_windowW) return -1;
*dwParam2 = (DWORD_PTR)mci_windowW;
......@@ -316,7 +311,7 @@ static int MCI_MapMsgAtoW(UINT msg, DWORD_PTR dwParam1, DWORD_PTR *dwParam2)
MCI_SYSINFO_PARMSW *mci_sysinfoW;
DWORD_PTR *ptr;
ptr = HeapAlloc(GetProcessHeap(), 0, sizeof(*mci_sysinfoW) + sizeof(DWORD_PTR));
ptr = malloc(sizeof(*mci_sysinfoW) + sizeof(DWORD_PTR));
if (!ptr) return -1;
*ptr++ = *dwParam2; /* save the previous pointer */
......@@ -328,7 +323,7 @@ static int MCI_MapMsgAtoW(UINT msg, DWORD_PTR dwParam1, DWORD_PTR *dwParam2)
/* Size is measured in numbers of characters, despite what MSDN says. */
mci_sysinfoW->dwRetSize = mci_sysinfoA->dwRetSize;
mci_sysinfoW->lpstrReturn = HeapAlloc(GetProcessHeap(), 0, mci_sysinfoW->dwRetSize * sizeof(WCHAR));
mci_sysinfoW->lpstrReturn = malloc(mci_sysinfoW->dwRetSize * sizeof(WCHAR));
mci_sysinfoW->dwNumber = mci_sysinfoA->dwNumber;
mci_sysinfoW->wDeviceType = mci_sysinfoA->wDeviceType;
return 1;
......@@ -340,7 +335,7 @@ static int MCI_MapMsgAtoW(UINT msg, DWORD_PTR dwParam1, DWORD_PTR *dwParam2)
MCI_DGV_INFO_PARMSW *mci_infoW;
DWORD_PTR *ptr;
ptr = HeapAlloc(GetProcessHeap(), 0, sizeof(*mci_infoW) + sizeof(DWORD_PTR));
ptr = malloc(sizeof(*mci_infoW) + sizeof(DWORD_PTR));
if (!ptr) return -1;
*ptr++ = *dwParam2; /* save the previous pointer */
......@@ -352,7 +347,7 @@ static int MCI_MapMsgAtoW(UINT msg, DWORD_PTR dwParam1, DWORD_PTR *dwParam2)
/* Size is measured in numbers of characters. */
mci_infoW->dwRetSize = mci_infoA->dwRetSize;
mci_infoW->lpstrReturn = HeapAlloc(GetProcessHeap(), 0, mci_infoW->dwRetSize * sizeof(WCHAR));
mci_infoW->lpstrReturn = malloc(mci_infoW->dwRetSize * sizeof(WCHAR));
if (dwParam1 & MCI_DGV_INFO_ITEM)
mci_infoW->dwItem = mci_infoA->dwItem;
return 1;
......@@ -365,7 +360,7 @@ static int MCI_MapMsgAtoW(UINT msg, DWORD_PTR dwParam1, DWORD_PTR *dwParam2)
MCI_OVLY_LOAD_PARMSA *mci_loadA = (MCI_OVLY_LOAD_PARMSA *)*dwParam2;
MCI_OVLY_LOAD_PARMSW *mci_loadW;
mci_loadW = HeapAlloc(GetProcessHeap(), 0, sizeof(*mci_loadW));
mci_loadW = malloc(sizeof(*mci_loadW));
if (!mci_loadW) return -1;
*dwParam2 = (DWORD_PTR)mci_loadW;
......@@ -385,7 +380,7 @@ static int MCI_MapMsgAtoW(UINT msg, DWORD_PTR dwParam1, DWORD_PTR *dwParam2)
MCI_VD_ESCAPE_PARMSA *mci_vd_escapeA = (MCI_VD_ESCAPE_PARMSA *)*dwParam2;
MCI_VD_ESCAPE_PARMSW *mci_vd_escapeW;
mci_vd_escapeW = HeapAlloc(GetProcessHeap(), 0, sizeof(*mci_vd_escapeW));
mci_vd_escapeW = malloc(sizeof(*mci_vd_escapeW));
if (!mci_vd_escapeW) return -1;
*dwParam2 = (DWORD_PTR)mci_vd_escapeW;
......@@ -425,16 +420,16 @@ static void MCI_UnmapMsgAtoW(UINT msg, DWORD_PTR dwParam1, DWORD_PTR dwParam2,
if (dwParam1 & MCI_OPEN_TYPE)
{
if (!(dwParam1 & MCI_OPEN_TYPE_ID))
HeapFree(GetProcessHeap(), 0, (LPWSTR)mci_openW->lpstrDeviceType);
free((WCHAR *)mci_openW->lpstrDeviceType);
}
if (dwParam1 & MCI_OPEN_ELEMENT)
{
if (!(dwParam1 & MCI_OPEN_ELEMENT_ID))
HeapFree(GetProcessHeap(), 0, (LPWSTR)mci_openW->lpstrElementName);
free((WCHAR *)mci_openW->lpstrElementName);
}
if (dwParam1 & MCI_OPEN_ALIAS)
HeapFree(GetProcessHeap(), 0, (LPWSTR)mci_openW->lpstrAlias);
HeapFree(GetProcessHeap(), 0, ptr);
free((WCHAR *)mci_openW->lpstrAlias);
free(ptr);
}
break;
case MCI_WINDOW:
......@@ -442,8 +437,8 @@ static void MCI_UnmapMsgAtoW(UINT msg, DWORD_PTR dwParam1, DWORD_PTR dwParam2,
{
MCI_ANIM_WINDOW_PARMSW *mci_windowW = (MCI_ANIM_WINDOW_PARMSW *)dwParam2;
HeapFree(GetProcessHeap(), 0, (void*)mci_windowW->lpstrText);
HeapFree(GetProcessHeap(), 0, mci_windowW);
free((void *)mci_windowW->lpstrText);
free(mci_windowW);
}
break;
......@@ -462,8 +457,8 @@ static void MCI_UnmapMsgAtoW(UINT msg, DWORD_PTR dwParam1, DWORD_PTR dwParam2,
NULL, NULL);
}
HeapFree(GetProcessHeap(), 0, mci_sysinfoW->lpstrReturn);
HeapFree(GetProcessHeap(), 0, ptr);
free(mci_sysinfoW->lpstrReturn);
free(ptr);
}
break;
case MCI_INFO:
......@@ -480,8 +475,8 @@ static void MCI_UnmapMsgAtoW(UINT msg, DWORD_PTR dwParam1, DWORD_PTR dwParam2,
NULL, NULL);
}
HeapFree(GetProcessHeap(), 0, mci_infoW->lpstrReturn);
HeapFree(GetProcessHeap(), 0, ptr);
free(mci_infoW->lpstrReturn);
free(ptr);
}
break;
case MCI_SAVE:
......@@ -491,8 +486,8 @@ static void MCI_UnmapMsgAtoW(UINT msg, DWORD_PTR dwParam1, DWORD_PTR dwParam2,
{ /* All these commands have the same layout: callback + string + optional rect */
MCI_OVLY_LOAD_PARMSW *mci_loadW = (MCI_OVLY_LOAD_PARMSW *)dwParam2;
HeapFree(GetProcessHeap(), 0, (void*)mci_loadW->lpfilename);
HeapFree(GetProcessHeap(), 0, mci_loadW);
free((void *)mci_loadW->lpfilename);
free(mci_loadW);
}
break;
case MCI_SOUND:
......@@ -500,8 +495,8 @@ static void MCI_UnmapMsgAtoW(UINT msg, DWORD_PTR dwParam1, DWORD_PTR dwParam2,
{ /* All these commands have the same layout: callback + string */
MCI_VD_ESCAPE_PARMSW *mci_vd_escapeW = (MCI_VD_ESCAPE_PARMSW *)dwParam2;
HeapFree(GetProcessHeap(), 0, (void*)mci_vd_escapeW->lpstrCommand);
HeapFree(GetProcessHeap(), 0, mci_vd_escapeW);
free((void *)mci_vd_escapeW->lpstrCommand);
free(mci_vd_escapeW);
}
break;
......@@ -726,7 +721,7 @@ static UINT MCI_SetCommandTable(HGLOBAL hMem, UINT uDevType)
count++;
} while (eid != MCI_END_COMMAND_LIST);
S_MciCmdTable[uTbl].aVerbs = HeapAlloc(GetProcessHeap(), 0, count * sizeof(LPCWSTR));
S_MciCmdTable[uTbl].aVerbs = malloc(count * sizeof(const WCHAR *));
S_MciCmdTable[uTbl].nVerbs = count;
lmem = S_MciCmdTable[uTbl].lpTable;
......@@ -771,10 +766,10 @@ static BOOL MCI_UnLoadMciDriver(LPWINE_MCIDRIVER wmd)
}
LeaveCriticalSection(&WINMM_cs);
HeapFree(GetProcessHeap(), 0, wmd->lpstrDeviceType);
HeapFree(GetProcessHeap(), 0, wmd->lpstrAlias);
free(wmd->lpstrDeviceType);
free(wmd->lpstrAlias);
HeapFree(GetProcessHeap(), 0, wmd);
free(wmd);
return TRUE;
}
......@@ -799,7 +794,7 @@ static BOOL MCI_OpenMciDriver(LPWINE_MCIDRIVER wmd, LPCWSTR drvTyp, DWORD_PTR lp
static DWORD MCI_LoadMciDriver(LPCWSTR _strDevTyp, LPWINE_MCIDRIVER* lpwmd)
{
LPWSTR strDevTyp = str_dup_upper(_strDevTyp);
LPWINE_MCIDRIVER wmd = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*wmd));
WINE_MCIDRIVER* wmd = calloc(1, sizeof(*wmd));
MCI_OPEN_DRIVER_PARMSW modp;
DWORD dwRet = 0;
......@@ -865,7 +860,7 @@ static DWORD MCI_LoadMciDriver(LPCWSTR _strDevTyp, LPWINE_MCIDRIVER* lpwmd)
return 0;
errCleanUp:
MCI_UnLoadMciDriver(wmd);
HeapFree(GetProcessHeap(), 0, strDevTyp);
free(strDevTyp);
*lpwmd = 0;
return dwRet;
}
......@@ -916,9 +911,8 @@ static DWORD MCI_FinishOpen(LPWINE_MCIDRIVER wmd, LPMCI_OPEN_PARMSW lpParms,
return MCIERR_DEVICE_OPEN;
}
if (alias) {
wmd->lpstrAlias = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(alias)+1) * sizeof(WCHAR));
wmd->lpstrAlias = wcsdup(alias);
if (!wmd->lpstrAlias) return MCIERR_OUT_OF_MEMORY;
lstrcpyW( wmd->lpstrAlias, alias);
/* In most cases, natives adds MCI_OPEN_ALIAS to the flags passed to the driver.
* Don't. The drivers don't care about the winmm alias. */
}
......@@ -1324,9 +1318,8 @@ DWORD WINAPI mciSendStringW(LPCWSTR lpstrCommand, LPWSTR lpstrRet,
return MCIERR_MISSING_COMMAND_STRING;
/* format is <command> <device> <optargs> */
if (!(verb = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(lpstrCommand)+1) * sizeof(WCHAR))))
if (!(verb = wcsdup(lpstrCommand)))
return MCIERR_OUT_OF_MEMORY;
lstrcpyW( verb, lpstrCommand );
CharLowerW(verb);
memset(&data, 0, sizeof(data));
......@@ -1575,8 +1568,8 @@ errCleanUp:
}
if (wMsg == MCI_OPEN && LOWORD(dwRet) && wmd)
MCI_UnLoadMciDriver(wmd);
HeapFree(GetProcessHeap(), 0, devType);
HeapFree(GetProcessHeap(), 0, verb);
free(devType);
free(verb);
return dwRet;
}
......@@ -1593,22 +1586,22 @@ DWORD WINAPI mciSendStringA(LPCSTR lpstrCommand, LPSTR lpstrRet,
/* FIXME: is there something to do with lpstrReturnString ? */
len = MultiByteToWideChar( CP_ACP, 0, lpstrCommand, -1, NULL, 0 );
lpwstrCommand = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
lpwstrCommand = malloc( len * sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, lpstrCommand, -1, lpwstrCommand, len );
if (lpstrRet)
{
if (uRetLen) *lpstrRet = '\0'; /* NT-w2k3 use memset(lpstrRet, 0, uRetLen); */
lpwstrRet = HeapAlloc(GetProcessHeap(), 0, uRetLen * sizeof(WCHAR));
lpwstrRet = malloc( uRetLen * sizeof(WCHAR) );
if (!lpwstrRet) {
HeapFree( GetProcessHeap(), 0, lpwstrCommand );
free( lpwstrCommand );
return MCIERR_OUT_OF_MEMORY;
}
}
ret = mciSendStringW(lpwstrCommand, lpwstrRet, uRetLen, hwndCallback);
if (!ret && lpwstrRet)
WideCharToMultiByte( CP_ACP, 0, lpwstrRet, -1, lpstrRet, uRetLen, NULL, NULL );
HeapFree(GetProcessHeap(), 0, lpwstrCommand);
HeapFree(GetProcessHeap(), 0, lpwstrRet);
free(lpwstrCommand);
free(lpwstrRet);
return ret;
}
......@@ -1688,7 +1681,7 @@ BOOL WINAPI mciFreeCommandResource(UINT uTable)
FreeResource(S_MciCmdTable[uTable].hMem);
S_MciCmdTable[uTable].hMem = NULL;
S_MciCmdTable[uTable].lpTable = NULL;
HeapFree(GetProcessHeap(), 0, S_MciCmdTable[uTable].aVerbs);
free(S_MciCmdTable[uTable].aVerbs);
S_MciCmdTable[uTable].aVerbs = 0;
S_MciCmdTable[uTable].nVerbs = 0;
return TRUE;
......@@ -2317,7 +2310,7 @@ UINT WINAPI mciGetDeviceIDA(LPCSTR lpstrName)
if (w)
{
ret = mciGetDeviceIDW(w);
HeapFree(GetProcessHeap(), 0, w);
free(w);
}
return ret;
}
......@@ -2383,7 +2376,7 @@ UINT WINAPI mciGetDeviceIDFromElementIDA(DWORD dwElementID, LPCSTR lpstrType)
if (w)
{
ret = mciGetDeviceIDFromElementIDW(dwElementID, w);
HeapFree(GetProcessHeap(), 0, w);
free(w);
}
return ret;
}
......
......@@ -319,7 +319,7 @@ static LPMMIOPROC MMIO_InstallIOProc(FOURCC fccIOProc, LPMMIOPROC pIOProc,
switch (dwFlags & (MMIO_INSTALLPROC|MMIO_REMOVEPROC|MMIO_FINDPROC)) {
case MMIO_INSTALLPROC:
/* Create new entry for the IOProc list */
pListNode = HeapAlloc(GetProcessHeap(), 0, sizeof(*pListNode));
pListNode = malloc(sizeof(*pListNode));
if (pListNode) {
/* Fill in this node */
pListNode->fourCC = fccIOProc;
......@@ -369,7 +369,7 @@ static LPMMIOPROC MMIO_InstallIOProc(FOURCC fccIOProc, LPMMIOPROC pIOProc,
struct IOProcList* ptmpNode = *ppListNode;
lpProc = (*ppListNode)->pIOProc;
*ppListNode = (*ppListNode)->pNext;
HeapFree(GetProcessHeap(), 0, ptmpNode);
free(ptmpNode);
}
}
break;
......@@ -498,7 +498,7 @@ static LPWINE_MMIO MMIO_Create(void)
static WORD MMIO_counter = 0;
LPWINE_MMIO wm;
wm = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINE_MMIO));
wm = calloc(1, sizeof(WINE_MMIO));
if (wm) {
EnterCriticalSection(&WINMM_cs);
/* lookup next unallocated WORD handle, with a non NULL value */
......@@ -527,7 +527,7 @@ static BOOL MMIO_Destroy(LPWINE_MMIO wm)
/* ...and destroy */
if (*m) {
*m = (*m)->lpNext;
HeapFree(GetProcessHeap(), 0, wm);
free(wm);
wm = NULL;
}
LeaveCriticalSection(&WINMM_cs);
......@@ -600,7 +600,7 @@ static MMRESULT MMIO_SetBuffer(WINE_MMIO* wm, void* pchBuffer, LONG cchBuffer,
/* free previous buffer if allocated */
if (wm->info.dwFlags & MMIO_ALLOCBUF) {
HeapFree(GetProcessHeap(), 0, wm->info.pchBuffer);
free(wm->info.pchBuffer);
wm->info.pchBuffer = NULL;
wm->info.dwFlags &= ~MMIO_ALLOCBUF;
}
......@@ -608,7 +608,7 @@ static MMRESULT MMIO_SetBuffer(WINE_MMIO* wm, void* pchBuffer, LONG cchBuffer,
if (pchBuffer) {
wm->info.pchBuffer = pchBuffer;
} else if (cchBuffer) {
if (!(wm->info.pchBuffer = HeapAlloc(GetProcessHeap(), 0, cchBuffer)))
if (!(wm->info.pchBuffer = malloc(cchBuffer)))
return MMIOERR_OUTOFMEMORY;
wm->info.dwFlags |= MMIO_ALLOCBUF;
} else {
......@@ -722,7 +722,7 @@ static HMMIO MMIO_Open(LPSTR szFileName, MMIOINFO* refmminfo, DWORD dwOpenFlags,
return wm->info.hmmio;
error1:
if (wm->info.dwFlags & MMIO_ALLOCBUF)
HeapFree(GetProcessHeap(), 0, wm->info.pchBuffer);
free(wm->info.pchBuffer);
if (wm->ioProc) wm->ioProc->count--;
error2:
MMIO_Destroy(wm);
......@@ -742,14 +742,14 @@ HMMIO WINAPI mmioOpenW(LPWSTR szFileName, MMIOINFO* lpmmioinfo,
{
INT len = WideCharToMultiByte( CP_ACP, 0, szFileName, -1, NULL, 0, NULL, NULL );
if (len < MAX_PATH) len = MAX_PATH;
szFn = HeapAlloc( GetProcessHeap(), 0, len );
szFn = malloc( len );
if (!szFn) return NULL;
WideCharToMultiByte( CP_ACP, 0, szFileName, -1, szFn, len, NULL, NULL );
}
ret = MMIO_Open(szFn, lpmmioinfo, dwOpenFlags, TRUE);
HeapFree(GetProcessHeap(), 0, szFn);
free(szFn);
return ret;
}
......@@ -1401,14 +1401,14 @@ MMRESULT WINAPI mmioRenameW(LPCWSTR szFileName, LPCWSTR szNewFileName,
if (szFileName)
{
len = WideCharToMultiByte( CP_ACP, 0, szFileName, -1, NULL, 0, NULL, NULL );
szFn = HeapAlloc( GetProcessHeap(), 0, len );
szFn = malloc( len );
if (!szFn) goto done;
WideCharToMultiByte( CP_ACP, 0, szFileName, -1, szFn, len, NULL, NULL );
}
if (szNewFileName)
{
len = WideCharToMultiByte( CP_ACP, 0, szNewFileName, -1, NULL, 0, NULL, NULL );
sznFn = HeapAlloc( GetProcessHeap(), 0, len );
sznFn = malloc( len );
if (!sznFn) goto done;
WideCharToMultiByte( CP_ACP, 0, szNewFileName, -1, sznFn, len, NULL, NULL );
}
......@@ -1416,7 +1416,7 @@ MMRESULT WINAPI mmioRenameW(LPCWSTR szFileName, LPCWSTR szNewFileName,
ret = mmioRenameA(szFn, sznFn, lpmmioinfo, dwFlags);
done:
HeapFree(GetProcessHeap(),0,szFn);
HeapFree(GetProcessHeap(),0,sznFn);
free(szFn);
free(sznFn);
return ret;
}
......@@ -201,8 +201,8 @@ static void PlaySound_Free(WINE_PLAYSOUND* wps)
PlaySoundCurrent = NULL;
SetEvent(psLastEvent);
LeaveCriticalSection(&WINMM_cs);
if (wps->bAlloc) HeapFree(GetProcessHeap(), 0, (void*)wps->pszSound);
HeapFree(GetProcessHeap(), 0, wps);
if (wps->bAlloc) free((void*)wps->pszSound);
free(wps);
}
static WINE_PLAYSOUND* PlaySound_Alloc(const void* pszSound, HMODULE hmod,
......@@ -210,7 +210,7 @@ static WINE_PLAYSOUND* PlaySound_Alloc(const void* pszSound, HMODULE hmod,
{
WINE_PLAYSOUND* wps;
wps = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*wps));
wps = calloc(1, sizeof(*wps));
if (!wps) return NULL;
wps->hMod = hmod;
......@@ -221,10 +221,8 @@ static WINE_PLAYSOUND* PlaySound_Alloc(const void* pszSound, HMODULE hmod,
{
if (fdwSound & SND_ASYNC)
{
LPWSTR sound = HeapAlloc(GetProcessHeap(), 0,
(lstrlenW(pszSound)+1) * sizeof(WCHAR));
if (!sound) goto oom_error;
wps->pszSound = lstrcpyW(sound, pszSound);
wps->pszSound = wcsdup(pszSound);
if (!wps->pszSound) goto oom_error;
wps->bAlloc = TRUE;
}
else
......@@ -244,8 +242,8 @@ static WINE_PLAYSOUND* PlaySound_Alloc(const void* pszSound, HMODULE hmod,
return wps;
oom_error:
if (wps->bAlloc) HeapFree(GetProcessHeap(), 0, (void*)wps->pszSound);
HeapFree(GetProcessHeap(), 0, wps);
if (wps->bAlloc) free((void*)wps->pszSound);
free(wps);
return NULL;
}
......@@ -359,7 +357,7 @@ static DWORD WINAPI proc_PlaySound(LPVOID arg)
TRACE("Chunk Found ckid=%.4s fccType=%08lx cksize=%08lX\n",
(LPSTR)&mmckInfo.ckid, mmckInfo.fccType, mmckInfo.cksize);
lpWaveFormat = HeapAlloc(GetProcessHeap(), 0, mmckInfo.cksize);
lpWaveFormat = malloc(mmckInfo.cksize);
if (!lpWaveFormat)
goto errCleanUp;
r = mmioRead(hmmio, (HPSTR)lpWaveFormat, mmckInfo.cksize);
......@@ -394,7 +392,7 @@ static DWORD WINAPI proc_PlaySound(LPVOID arg)
/* make it so that 3 buffers per second are needed */
bufsize = (((lpWaveFormat->nAvgBytesPerSec / 3) - 1) / lpWaveFormat->nBlockAlign + 1) *
lpWaveFormat->nBlockAlign;
waveHdr = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(WAVEHDR) + 2 * bufsize);
waveHdr = malloc(2 * sizeof(WAVEHDR) + 2 * bufsize);
if (!waveHdr)
goto errCleanUp;
waveHdr[0].lpData = (char*)waveHdr + 2 * sizeof(WAVEHDR);
......@@ -448,7 +446,7 @@ static DWORD WINAPI proc_PlaySound(LPVOID arg)
errCleanUp:
TRACE("Done playing=%s => %s!\n", debugstr_w(wps->pszSound), bRet ? "ok" : "ko");
HeapFree(GetProcessHeap(), 0, lpWaveFormat);
free(lpWaveFormat);
if (hWave)
{
EnterCriticalSection(&WINMM_cs);
......@@ -459,7 +457,7 @@ errCleanUp:
Sleep(100);
}
CloseHandle(s.hEvent);
HeapFree(GetProcessHeap(), 0, waveHdr);
free(waveHdr);
if (hmmio) mmioClose(hmmio, 0);
PlaySound_Free(wps);
......
......@@ -234,11 +234,11 @@ void WINMM_DeleteWaveform(void)
DeleteCriticalSection(&mmdevice->lock);
}
HeapFree(GetProcessHeap(), 0, g_out_mmdevices);
HeapFree(GetProcessHeap(), 0, g_in_mmdevices);
free(g_out_mmdevices);
free(g_in_mmdevices);
HeapFree(GetProcessHeap(), 0, g_device_handles);
HeapFree(GetProcessHeap(), 0, g_handle_devices);
free(g_device_handles);
free(g_handle_devices);
DeleteCriticalSection(&g_devthread_lock);
}
......@@ -289,8 +289,7 @@ static WINMM_Device *WINMM_FindUnusedDevice(WINMM_Device **devices,
WINMM_Device *device = devices[i];
if(!device){
device = devices[i] = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY, sizeof(WINMM_Device));
device = devices[i] = calloc(1, sizeof(WINMM_Device));
if(!device)
return NULL;
......@@ -578,18 +577,16 @@ static HRESULT WINMM_EnumDevices(WINMM_MMDevice **devices,
UINT n, count = 1;
IMMDevice *def_dev = NULL;
*devices = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(WINMM_MMDevice) * (*devcount));
*devices = calloc(*devcount, sizeof(WINMM_MMDevice));
if(!*devices){
IMMDeviceCollection_Release(devcoll);
return E_OUTOFMEMORY;
}
*map = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(WINMM_MMDevice *) * (*devcount));
*map = calloc(*devcount, sizeof(WINMM_MMDevice *));
if(!*map){
IMMDeviceCollection_Release(devcoll);
HeapFree(GetProcessHeap(), 0, *devices);
free(*devices);
return E_OUTOFMEMORY;
}
......@@ -772,7 +769,7 @@ static HRESULT reroute_mapper_device(WINMM_Device *device, BOOL is_out)
return E_FAIL;
}
HeapFree(GetProcessHeap(), 0, info.format);
free(info.format);
if(!stopped){
if(is_out)
......@@ -1099,7 +1096,7 @@ static LRESULT WINMM_OpenDevice(WINMM_Device *device, WINMM_OpenInfo *info,
/* we aren't guaranteed that the struct in lpFormat is a full
* WAVEFORMATEX struct, which IAC::IsFormatSupported requires */
device->orig_fmt = HeapAlloc(GetProcessHeap(), 0, sizeof(WAVEFORMATEX));
device->orig_fmt = malloc(sizeof(WAVEFORMATEX));
memcpy(device->orig_fmt, info->format, sizeof(PCMWAVEFORMAT));
device->orig_fmt->cbSize = 0;
if(device->orig_fmt->wBitsPerSample % 8 != 0){
......@@ -1116,8 +1113,7 @@ static LRESULT WINMM_OpenDevice(WINMM_Device *device, WINMM_OpenInfo *info,
device->orig_fmt->nAvgBytesPerSec = device->orig_fmt->nSamplesPerSec * device->orig_fmt->nBlockAlign;
}
}else{
device->orig_fmt = HeapAlloc(GetProcessHeap(), 0,
sizeof(WAVEFORMATEX) + info->format->cbSize);
device->orig_fmt = malloc(sizeof(WAVEFORMATEX) + info->format->cbSize);
memcpy(device->orig_fmt, info->format,
sizeof(WAVEFORMATEX) + info->format->cbSize);
}
......@@ -1169,16 +1165,10 @@ static LRESULT WINMM_OpenDevice(WINMM_Device *device, WINMM_OpenInfo *info,
/* As the devices thread is waiting on g_device_handles, it can
* only be modified from within this same thread. */
if(g_device_handles){
g_device_handles = HeapReAlloc(GetProcessHeap(), 0, g_device_handles,
sizeof(HANDLE) * (g_devhandle_count + 1));
g_handle_devices = HeapReAlloc(GetProcessHeap(), 0, g_handle_devices,
sizeof(WINMM_Device *) * (g_devhandle_count + 1));
}else{
g_device_handles = HeapAlloc(GetProcessHeap(), 0, sizeof(HANDLE));
g_handle_devices = HeapAlloc(GetProcessHeap(), 0,
sizeof(WINMM_Device *));
}
g_device_handles = realloc(g_device_handles,
sizeof(HANDLE) * (g_devhandle_count + 1));
g_handle_devices = realloc(g_handle_devices,
sizeof(WINMM_Device *) * (g_devhandle_count + 1));
g_device_handles[g_devhandle_count] = device->event;
g_handle_devices[g_devhandle_count] = device;
++g_devhandle_count;
......@@ -1427,7 +1417,7 @@ static HRESULT WINMM_CloseDevice(WINMM_Device *device)
IAudioClock_Release(device->clock);
device->clock = NULL;
HeapFree(GetProcessHeap(), 0, device->orig_fmt);
free(device->orig_fmt);
return S_OK;
}
......@@ -1499,7 +1489,7 @@ static LRESULT WINMM_PrepareHeader(HWAVE hwave, WAVEHDR *header)
return mr;
}
ash = HeapAlloc(GetProcessHeap(), 0, sizeof(ACMSTREAMHEADER) + size);
ash = malloc(sizeof(ACMSTREAMHEADER) + size);
if(!ash){
LeaveCriticalSection(&device->lock);
return MMSYSERR_NOMEM;
......@@ -1517,7 +1507,7 @@ static LRESULT WINMM_PrepareHeader(HWAVE hwave, WAVEHDR *header)
mr = acmStreamPrepareHeader(device->acm_handle, ash, 0);
if(mr != MMSYSERR_NOERROR){
HeapFree(GetProcessHeap(), 0, ash);
free(ash);
LeaveCriticalSection(&device->lock);
return mr;
}
......@@ -1547,7 +1537,7 @@ static LRESULT WINMM_UnprepareHeader(HWAVE hwave, WAVEHDR *header)
acmStreamUnprepareHeader(device->acm_handle, ash, 0);
HeapFree(GetProcessHeap(), 0, ash);
free(ash);
}
LeaveCriticalSection(&device->lock);
......@@ -1798,7 +1788,7 @@ static void WID_PullACMData(WINMM_Device *device)
device->acm_hdr.cbSrcLength = packet * device->bytes_per_frame;
device->acm_hdr.cbSrcLengthUsed = 0;
device->acm_hdr.dwSrcUser = 0;
device->acm_hdr.pbDst = HeapAlloc(GetProcessHeap(), 0, packet_bytes);
device->acm_hdr.pbDst = malloc(packet_bytes);
device->acm_hdr.cbDstLength = packet_bytes;
device->acm_hdr.cbDstLengthUsed = 0;
device->acm_hdr.dwDstUser = 0;
......@@ -1844,7 +1834,7 @@ static void WID_PullACMData(WINMM_Device *device)
if(device->acm_offs >= WINMM_FixedBufferLen(device->acm_hdr.cbDstLengthUsed, device)){
acmStreamUnprepareHeader(device->acm_handle, &device->acm_hdr, 0);
HeapFree(GetProcessHeap(), 0, device->acm_hdr.pbDst);
free(device->acm_hdr.pbDst);
device->acm_hdr.cbDstLength = 0;
device->acm_hdr.cbDstLengthUsed = 0;
......@@ -1856,7 +1846,7 @@ static void WID_PullACMData(WINMM_Device *device)
/* out of WAVEHDRs to write into, so toss the rest of this packet */
acmStreamUnprepareHeader(device->acm_handle, &device->acm_hdr, 0);
HeapFree(GetProcessHeap(), 0, device->acm_hdr.pbDst);
free(device->acm_hdr.pbDst);
device->acm_hdr.cbDstLength = 0;
device->acm_hdr.cbDstLengthUsed = 0;
}
......@@ -2685,14 +2675,14 @@ UINT WINAPI waveOutGetErrorTextA(UINT uError, LPSTR lpText, UINT uSize)
else if (uSize == 0) ret = MMSYSERR_NOERROR;
else
{
LPWSTR xstr = HeapAlloc(GetProcessHeap(), 0, uSize * sizeof(WCHAR));
WCHAR *xstr = malloc(uSize * sizeof(WCHAR));
if (!xstr) ret = MMSYSERR_NOMEM;
else
{
ret = waveOutGetErrorTextW(uError, xstr, uSize);
if (ret == MMSYSERR_NOERROR)
WideCharToMultiByte(CP_ACP, 0, xstr, -1, lpText, uSize, NULL, NULL);
HeapFree(GetProcessHeap(), 0, xstr);
free(xstr);
}
}
return ret;
......@@ -3065,7 +3055,7 @@ UINT WINAPI waveOutGetVolume(HWAVEOUT hWaveOut, DWORD *out)
return MMSYSERR_ERROR;
}
vols = HeapAlloc(GetProcessHeap(), 0, sizeof(float) * channels);
vols = malloc(sizeof(float) * channels);
if(!vols){
LeaveCriticalSection(&device->lock);
return MMSYSERR_NOMEM;
......@@ -3074,7 +3064,7 @@ UINT WINAPI waveOutGetVolume(HWAVEOUT hWaveOut, DWORD *out)
hr = IAudioStreamVolume_GetAllVolumes(device->volume, channels, vols);
if(FAILED(hr)){
LeaveCriticalSection(&device->lock);
HeapFree(GetProcessHeap(), 0, vols);
free(vols);
WARN("GetAllVolumes failed: %08lx\n", hr);
return MMSYSERR_ERROR;
}
......@@ -3085,7 +3075,7 @@ UINT WINAPI waveOutGetVolume(HWAVEOUT hWaveOut, DWORD *out)
if(channels > 1)
*out |= ((UINT16)(vols[1] * (DWORD)0xFFFF)) << 16;
HeapFree(GetProcessHeap(), 0, vols);
free(vols);
return MMSYSERR_NOERROR;
}
......@@ -3114,7 +3104,7 @@ UINT WINAPI waveOutSetVolume(HWAVEOUT hWaveOut, DWORD in)
return MMSYSERR_ERROR;
}
vols = HeapAlloc(GetProcessHeap(), 0, sizeof(float) * channels);
vols = malloc(sizeof(float) * channels);
if(!vols){
LeaveCriticalSection(&device->lock);
return MMSYSERR_NOMEM;
......@@ -3123,7 +3113,7 @@ UINT WINAPI waveOutSetVolume(HWAVEOUT hWaveOut, DWORD in)
hr = IAudioStreamVolume_GetAllVolumes(device->volume, channels, vols);
if(FAILED(hr)){
LeaveCriticalSection(&device->lock);
HeapFree(GetProcessHeap(), 0, vols);
free(vols);
WARN("GetAllVolumes failed: %08lx\n", hr);
return MMSYSERR_ERROR;
}
......@@ -3135,14 +3125,14 @@ UINT WINAPI waveOutSetVolume(HWAVEOUT hWaveOut, DWORD in)
hr = IAudioStreamVolume_SetAllVolumes(device->volume, channels, vols);
if(FAILED(hr)){
LeaveCriticalSection(&device->lock);
HeapFree(GetProcessHeap(), 0, vols);
free(vols);
WARN("SetAllVolumes failed: %08lx\n", hr);
return MMSYSERR_ERROR;
}
LeaveCriticalSection(&device->lock);
HeapFree(GetProcessHeap(), 0, vols);
free(vols);
return MMSYSERR_NOERROR;
}
......@@ -3922,7 +3912,7 @@ UINT WINAPI mixerGetControlDetailsA(HMIXEROBJ hmix, LPMIXERCONTROLDETAILS lpmcdA
if (lpmcdA->cMultipleItems != 0) {
size *= lpmcdA->cMultipleItems;
}
pDetailsW = HeapAlloc(GetProcessHeap(), 0, size);
pDetailsW = malloc(size);
lpmcdA->paDetails = pDetailsW;
lpmcdA->cbDetails = sizeof(MIXERCONTROLDETAILS_LISTTEXTW);
/* set up lpmcd->paDetails */
......@@ -3941,7 +3931,7 @@ UINT WINAPI mixerGetControlDetailsA(HMIXEROBJ hmix, LPMIXERCONTROLDETAILS lpmcdA
pDetailsA -= lpmcdA->cMultipleItems * lpmcdA->cChannels;
pDetailsW -= lpmcdA->cMultipleItems * lpmcdA->cChannels;
}
HeapFree(GetProcessHeap(), 0, pDetailsW);
free(pDetailsW);
lpmcdA->paDetails = pDetailsA;
lpmcdA->cbDetails = sizeof(MIXERCONTROLDETAILS_LISTTEXTA);
}
......@@ -3983,8 +3973,7 @@ UINT WINAPI mixerGetLineControlsA(HMIXEROBJ hmix, LPMIXERLINECONTROLSA lpmlcA,
mlcW.cControls = lpmlcA->cControls;
}
mlcW.cbmxctrl = sizeof(MIXERCONTROLW);
mlcW.pamxctrl = HeapAlloc(GetProcessHeap(), 0,
mlcW.cControls * mlcW.cbmxctrl);
mlcW.pamxctrl = malloc(mlcW.cControls * mlcW.cbmxctrl);
ret = mixerGetLineControlsW(hmix, &mlcW, fdwControls);
......@@ -4016,7 +4005,7 @@ UINT WINAPI mixerGetLineControlsA(HMIXEROBJ hmix, LPMIXERLINECONTROLSA lpmlcA,
}
}
HeapFree(GetProcessHeap(), 0, mlcW.pamxctrl);
free(mlcW.pamxctrl);
return ret;
}
......
......@@ -349,14 +349,14 @@ UINT WINAPI midiOutGetErrorTextA(UINT uError, LPSTR lpText, UINT uSize)
else if (uSize == 0) ret = MMSYSERR_NOERROR;
else
{
LPWSTR xstr = HeapAlloc(GetProcessHeap(), 0, uSize * sizeof(WCHAR));
WCHAR *xstr = malloc(uSize * sizeof(WCHAR));
if (!xstr) ret = MMSYSERR_NOMEM;
else
{
ret = midiOutGetErrorTextW(uError, xstr, uSize);
if (ret == MMSYSERR_NOERROR)
WideCharToMultiByte(CP_ACP, 0, xstr, -1, lpText, uSize, NULL, NULL);
HeapFree(GetProcessHeap(), 0, xstr);
free(xstr);
}
}
return ret;
......@@ -957,7 +957,7 @@ static WINE_MIDIStream *wine_midi_stream_allocate(void)
stream_id++;
if (stream_id < 0xFFFFFFFF &&
(stream = HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_MIDIStream))))
(stream = malloc(sizeof(WINE_MIDIStream))))
{
stream->dwStreamID = stream_id;
wine_rb_put(&wine_midi_streams, &stream_id, &stream->entry);
......@@ -972,7 +972,7 @@ static void wine_midi_stream_free(WINE_MIDIStream *stream)
EnterCriticalSection(&WINMM_cs);
wine_rb_remove(&wine_midi_streams, &stream->entry);
HeapFree(GetProcessHeap(), 0, stream);
free(stream);
LeaveCriticalSection(&WINMM_cs);
}
......@@ -1392,7 +1392,7 @@ MMRESULT WINAPI midiStreamOpen(HMIDISTRM* lphMidiStrm, LPUINT lpuDeviceID,
mosm.wDeviceID = *lpuDeviceID;
lpwm = MIDI_OutAlloc(&hMidiOut, &dwCallback, &dwInstance, &fdwOpen, 1, &mosm);
if (!lpwm) {
HeapFree(GetProcessHeap(), 0, lpMidiStrm);
free(lpMidiStrm);
return MMSYSERR_NOMEM;
}
lpMidiStrm->hDevice = hMidiOut;
......@@ -1404,7 +1404,7 @@ MMRESULT WINAPI midiStreamOpen(HMIDISTRM* lphMidiStrm, LPUINT lpuDeviceID,
ret = MMDRV_Open(&lpwm->mld, MODM_OPEN, (DWORD_PTR)&lpwm->mod, CALLBACK_NULL);
if (ret != MMSYSERR_NOERROR) {
MMDRV_Free(hMidiOut, &lpwm->mld);
HeapFree(GetProcessHeap(), 0, lpMidiStrm);
free(lpMidiStrm);
return ret;
}
......@@ -1682,7 +1682,7 @@ static DWORD WINAPI mmTaskRun(void* pmt)
struct mm_starter mms;
memcpy(&mms, pmt, sizeof(struct mm_starter));
HeapFree(GetProcessHeap(), 0, pmt);
free(pmt);
mms.cb(mms.client);
if (mms.event) SetEvent(mms.event);
return 0;
......@@ -1697,7 +1697,7 @@ UINT WINAPI mmTaskCreate(LPTASKCALLBACK cb, HANDLE* ph, DWORD_PTR client)
HANDLE hEvent = 0;
struct mm_starter *mms;
mms = HeapAlloc(GetProcessHeap(), 0, sizeof(struct mm_starter));
mms = malloc(sizeof(struct mm_starter));
if (mms == NULL) return TASKERR_OUTOFMEMORY;
mms->cb = cb;
......@@ -1707,7 +1707,7 @@ UINT WINAPI mmTaskCreate(LPTASKCALLBACK cb, HANDLE* ph, DWORD_PTR client)
hThread = CreateThread(0, 0, mmTaskRun, mms, 0, NULL);
if (!hThread) {
HeapFree(GetProcessHeap(), 0, mms);
free(mms);
if (hEvent) CloseHandle(hEvent);
return TASKERR_OUTOFMEMORY;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment