Commit 76205649 authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

dplayx: Use CRT allocation functions.

parent a3209dae
......@@ -96,9 +96,9 @@ static ULONG WINAPI IDirectPlaySPImpl_Release( IDirectPlaySP *iface )
if( !ref )
{
HeapFree( GetProcessHeap(), 0, This->remote_data );
HeapFree( GetProcessHeap(), 0, This->local_data );
HeapFree( GetProcessHeap(), 0, This );
free( This->remote_data );
free( This->local_data );
free( This );
}
return ref;
......@@ -531,7 +531,7 @@ static HRESULT WINAPI IDirectPlaySPImpl_SetSPPlayerData( IDirectPlaySP *iface, D
return DPERR_INVALIDPLAYER;
}
lpPlayerData = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, dwDataSize );
lpPlayerData = malloc( dwDataSize );
CopyMemory( lpPlayerData, lpData, dwDataSize );
if( dwFlags == DPSET_LOCAL )
......@@ -635,19 +635,19 @@ static HRESULT WINAPI IDirectPlaySPImpl_SetSPData( IDirectPlaySP *iface, void *l
}
#endif
lpSpData = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, dwDataSize );
lpSpData = malloc( dwDataSize );
CopyMemory( lpSpData, lpData, dwDataSize );
/* If we have data already allocated, free it and replace it */
if( dwFlags == DPSET_REMOTE )
{
HeapFree( GetProcessHeap(), 0, This->remote_data );
free( This->remote_data );
This->remote_data_size = dwDataSize;
This->remote_data = lpSpData;
}
else if ( dwFlags == DPSET_LOCAL )
{
HeapFree( GetProcessHeap(), 0, This->local_data );
free( This->local_data );
This->local_data = lpSpData;
This->local_data_size = dwDataSize;
}
......@@ -691,7 +691,7 @@ HRESULT dplaysp_create( REFIID riid, void **ppv, IDirectPlayImpl *dp )
TRACE( "(%s, %p)\n", debugstr_guid( riid ), ppv );
*ppv = NULL;
obj = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *obj ) );
obj = calloc( 1, sizeof( *obj ) );
if ( !obj )
return DPERR_OUTOFMEMORY;
......@@ -711,6 +711,5 @@ HRESULT dplaysp_create( REFIID riid, void **ppv, IDirectPlayImpl *dp )
LPVOID DPSP_CreateSPPlayerData(void)
{
TRACE( "Creating SPPlayer data struct\n" );
return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof( DP_SPPLAYERDATA ) );
return calloc( 1, sizeof( DP_SPPLAYERDATA ) );
}
......@@ -59,7 +59,7 @@ DWORD CreateLobbyMessageReceptionThread( HANDLE hNotifyEvent, HANDLE hStart,
LPMSGTHREADINFO lpThreadInfo;
HANDLE hThread;
lpThreadInfo = HeapAlloc( GetProcessHeap(), 0, sizeof( *lpThreadInfo ) );
lpThreadInfo = malloc( sizeof( *lpThreadInfo ) );
if( lpThreadInfo == NULL )
{
return 0;
......@@ -102,7 +102,7 @@ DWORD CreateLobbyMessageReceptionThread( HANDLE hNotifyEvent, HANDLE hStart,
error:
HeapFree( GetProcessHeap(), 0, lpThreadInfo );
free( lpThreadInfo );
return 0;
}
......@@ -147,7 +147,7 @@ static DWORD CALLBACK DPL_MSG_ThreadMain( LPVOID lpContext )
end_of_thread:
TRACE( "Msg thread exiting!\n" );
HeapFree( GetProcessHeap(), 0, lpThreadInfo );
free( lpThreadInfo );
return 0;
}
......@@ -190,7 +190,7 @@ HRESULT DP_MSG_SendRequestPlayerId( IDirectPlayImpl *This, DWORD dwFlags, DPID *
dwMsgSize = This->dp2->spData.dwSPHeaderSize + sizeof( *lpMsgBody );
lpMsg = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, dwMsgSize );
lpMsg = calloc( 1, dwMsgSize );
lpMsgBody = (LPDPMSG_REQUESTNEWPLAYERID)( (BYTE*)lpMsg +
This->dp2->spData.dwSPHeaderSize );
......@@ -241,7 +241,7 @@ HRESULT DP_MSG_SendRequestPlayerId( IDirectPlayImpl *This, DWORD dwFlags, DPID *
* for several different messages?
*/
HeapFree( GetProcessHeap(), 0, lpMsg );
free( lpMsg );
}
return hr;
......@@ -256,7 +256,7 @@ HRESULT DP_MSG_ForwardPlayerCreation( IDirectPlayImpl *This, DPID dpidServer )
dwMsgSize = This->dp2->spData.dwSPHeaderSize + sizeof( *lpMsgBody );
lpMsg = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, dwMsgSize );
lpMsg = calloc( 1, dwMsgSize );
lpMsgBody = (LPDPMSG_FORWARDADDPLAYER)( (BYTE*)lpMsg +
This->dp2->spData.dwSPHeaderSize );
......@@ -428,9 +428,7 @@ void DP_MSG_ReplyReceived( IDirectPlayImpl *This, WORD wCommandId, const void *l
if( lpReplyList != NULL )
{
lpReplyList->replyExpected.dwMsgBodySize = dwMsgBodySize;
lpReplyList->replyExpected.lpReplyMsg = HeapAlloc( GetProcessHeap(),
HEAP_ZERO_MEMORY,
dwMsgBodySize );
lpReplyList->replyExpected.lpReplyMsg = malloc( dwMsgBodySize );
CopyMemory( lpReplyList->replyExpected.lpReplyMsg,
lpcMsgBody, dwMsgBodySize );
......@@ -452,7 +450,7 @@ void DP_MSG_ToSelf( IDirectPlayImpl *This, DPID dpidSelf )
dwMsgSize = This->dp2->spData.dwSPHeaderSize + sizeof( *lpMsgBody );
lpMsg = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, dwMsgSize );
lpMsg = calloc( 1, dwMsgSize );
lpMsgBody = (LPDPMSG_SENDENVELOPE)( (BYTE*)lpMsg +
This->dp2->spData.dwSPHeaderSize );
......
......@@ -115,7 +115,7 @@ static void dplobby_destroy(IDirectPlayLobbyImpl *obj)
DPQ_DELETEQ( obj->msgs, msgs, LPDPLMSG, cbDeleteElemFromHeap );
obj->lock.DebugInfo->Spare[0] = 0;
DeleteCriticalSection( &obj->lock );
HeapFree( GetProcessHeap(), 0, obj );
free( obj );
}
static HRESULT WINAPI IDirectPlayLobbyAImpl_QueryInterface( IDirectPlayLobbyA *iface, REFIID riid,
......@@ -405,7 +405,7 @@ static HRESULT DPL_ConnectEx( IDirectPlayLobbyImpl *This, DWORD dwFlags, REFIID
return hr;
}
lpConn = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, dwConnSize );
lpConn = calloc( 1, dwConnSize );
if( lpConn == NULL )
{
......@@ -417,7 +417,7 @@ static HRESULT DPL_ConnectEx( IDirectPlayLobbyImpl *This, DWORD dwFlags, REFIID
0, lpConn, &dwConnSize );
if( FAILED( hr ) )
{
HeapFree( GetProcessHeap(), 0, lpConn );
free( lpConn );
return hr;
}
......@@ -442,7 +442,7 @@ static HRESULT DPL_ConnectEx( IDirectPlayLobbyImpl *This, DWORD dwFlags, REFIID
hr = IDirectPlayX_Open( (*(LPDIRECTPLAY2*)lplpDP), lpConn->lpSessionDesc,
dwOpenFlags );
HeapFree( GetProcessHeap(), 0, lpConn );
free( lpConn );
return hr;
}
......@@ -1153,8 +1153,7 @@ static BOOL CALLBACK RunApplicationA_EnumLocalApplications
}
else
{
if ((lpData->lpszCommandLine = HeapAlloc( GetProcessHeap(), 0, strlen(returnBuffer)+1 )))
strcpy( lpData->lpszCommandLine, returnBuffer );
lpData->lpszCommandLine = strdup( returnBuffer );
}
sizeOfReturnBuffer = 200;
......@@ -1167,8 +1166,7 @@ static BOOL CALLBACK RunApplicationA_EnumLocalApplications
}
else
{
if ((lpData->lpszCurrentDirectory = HeapAlloc( GetProcessHeap(), 0, strlen(returnBuffer)+1 )))
strcpy( lpData->lpszCurrentDirectory, returnBuffer );
lpData->lpszCurrentDirectory = strdup( returnBuffer );
}
sizeOfReturnBuffer = 200;
......@@ -1181,8 +1179,7 @@ static BOOL CALLBACK RunApplicationA_EnumLocalApplications
}
else
{
if ((lpData->lpszFileName = HeapAlloc( GetProcessHeap(), 0, strlen(returnBuffer)+1 )))
strcpy( lpData->lpszFileName, returnBuffer );
lpData->lpszFileName = strdup( returnBuffer );
}
sizeOfReturnBuffer = 200;
......@@ -1195,8 +1192,7 @@ static BOOL CALLBACK RunApplicationA_EnumLocalApplications
}
else
{
if ((lpData->lpszPath = HeapAlloc( GetProcessHeap(), 0, strlen(returnBuffer)+1 )))
strcpy( lpData->lpszPath, returnBuffer );
lpData->lpszPath = strdup( returnBuffer );
}
return FALSE; /* No need to keep going as we found what we wanted */
......@@ -1330,16 +1326,15 @@ static HRESULT WINAPI IDirectPlayLobby3AImpl_RunApplication( IDirectPlayLobby3A
strcpy( temp, enumData.lpszPath );
strcat( temp, "\\" );
strcat( temp, enumData.lpszFileName );
HeapFree( GetProcessHeap(), 0, enumData.lpszPath );
HeapFree( GetProcessHeap(), 0, enumData.lpszFileName );
if ((appName = HeapAlloc( GetProcessHeap(), 0, strlen(temp)+1 ))) strcpy( appName, temp );
free( enumData.lpszPath );
free( enumData.lpszFileName );
appName = strdup( temp );
/* Now the command line */
strcat( temp, " " );
strcat( temp, enumData.lpszCommandLine );
HeapFree( GetProcessHeap(), 0, enumData.lpszCommandLine );
if ((enumData.lpszCommandLine = HeapAlloc( GetProcessHeap(), 0, strlen(temp)+1 )))
strcpy( enumData.lpszCommandLine, temp );
free( enumData.lpszCommandLine );
enumData.lpszCommandLine = strdup( temp );
ZeroMemory( &startupInfo, sizeof( startupInfo ) );
startupInfo.cb = sizeof( startupInfo );
......@@ -1362,17 +1357,17 @@ static HRESULT WINAPI IDirectPlayLobby3AImpl_RunApplication( IDirectPlayLobby3A
{
ERR( "Failed to create process for app %s\n", appName );
HeapFree( GetProcessHeap(), 0, appName );
HeapFree( GetProcessHeap(), 0, enumData.lpszCommandLine );
HeapFree( GetProcessHeap(), 0, enumData.lpszCurrentDirectory );
free( appName );
free( enumData.lpszCommandLine );
free( enumData.lpszCurrentDirectory );
LeaveCriticalSection( &This->lock );
return DPERR_CANTCREATEPROCESS;
}
HeapFree( GetProcessHeap(), 0, appName );
HeapFree( GetProcessHeap(), 0, enumData.lpszCommandLine );
HeapFree( GetProcessHeap(), 0, enumData.lpszCurrentDirectory );
free( appName );
free( enumData.lpszCommandLine );
free( enumData.lpszCurrentDirectory );
/* Reserve this global application id! */
if( !DPLAYX_CreateLobbyApplication( newProcessInfo.dwProcessId ) )
......@@ -2029,7 +2024,7 @@ HRESULT dplobby_create( REFIID riid, void **ppv )
TRACE( "(%s, %p)\n", debugstr_guid( riid ), ppv );
*ppv = NULL;
obj = HeapAlloc( GetProcessHeap(), 0, sizeof( *obj ) );
obj = malloc( sizeof( *obj ) );
if ( !obj )
return DPERR_OUTOFMEMORY;
......
......@@ -73,7 +73,7 @@ static ULONG WINAPI IDPLobbySPImpl_Release( IDPLobbySP *iface )
TRACE( "(%p) ref=%ld\n", This, ref );
if( !ref )
HeapFree( GetProcessHeap(), 0, This );
free( This );
return ref;
}
......@@ -235,7 +235,7 @@ HRESULT dplobbysp_create( REFIID riid, void **ppv, IDirectPlayImpl *dp )
TRACE( "(%s, %p)\n", debugstr_guid( riid ), ppv );
*ppv = NULL;
obj = HeapAlloc( GetProcessHeap(), 0, sizeof( *obj ) );
obj = malloc( sizeof( *obj ) );
if ( !obj )
return DPERR_OUTOFMEMORY;
......
......@@ -105,7 +105,7 @@ void NS_AddRemoteComputerAsNameServer( LPCVOID lpcNSAddrHdr
}
/* Add this to the list */
lpCacheNode = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *lpCacheNode ) );
lpCacheNode = calloc( 1, sizeof( *lpCacheNode ) );
if( lpCacheNode == NULL )
{
......@@ -113,22 +113,21 @@ void NS_AddRemoteComputerAsNameServer( LPCVOID lpcNSAddrHdr
return;
}
lpCacheNode->lpNSAddrHdr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
dwHdrSize );
lpCacheNode->lpNSAddrHdr = malloc( dwHdrSize );
CopyMemory( lpCacheNode->lpNSAddrHdr, lpcNSAddrHdr, dwHdrSize );
lpCacheNode->data = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(lpCacheNode->data) ) );
lpCacheNode->data = calloc( 1, sizeof( *(lpCacheNode->data) ) );
if( lpCacheNode->data == NULL )
{
ERR( "no memory for SESSIONDESC2\n" );
HeapFree( GetProcessHeap(), 0, lpCacheNode );
free( lpCacheNode );
return;
}
*lpCacheNode->data = lpcMsg->sd;
len = WideCharToMultiByte( CP_ACP, 0, (LPCWSTR)(lpcMsg+1), -1, NULL, 0, NULL, NULL );
if ((lpCacheNode->data->lpszSessionNameA = HeapAlloc( GetProcessHeap(), 0, len )))
if ((lpCacheNode->data->lpszSessionNameA = malloc( len )))
{
WideCharToMultiByte( CP_ACP, 0, (LPCWSTR)(lpcMsg+1), -1,
lpCacheNode->data->lpszSessionNameA, len, NULL, NULL );
......@@ -183,7 +182,7 @@ void NS_SetLocalAddr( LPVOID lpNSInfo, LPCVOID lpHdr, DWORD dwHdrSize )
{
lpNSCache lpCache = (lpNSCache)lpNSInfo;
lpCache->lpLocalAddrHdr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, dwHdrSize );
lpCache->lpLocalAddrHdr = malloc( dwHdrSize );
CopyMemory( lpCache->lpLocalAddrHdr, lpHdr, dwHdrSize );
}
......@@ -205,8 +204,7 @@ HRESULT NS_SendSessionRequestBroadcast( LPCGUID lpcGuid,
FIXME( ": not all data fields are correct\n" );
data.dwMessageSize = lpSpData->dwSPHeaderSize + sizeof( *lpMsg ); /*FIXME!*/
data.lpMessage = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
data.dwMessageSize );
data.lpMessage = calloc( 1, data.dwMessageSize );
data.lpISP = lpSpData->lpISP;
data.bReturnStatus = (dwFlags & DPENUMSESSIONS_RETURNSTATUS) != 0;
......@@ -232,9 +230,9 @@ static DPQ_DECL_DELETECB( cbDeleteNSNodeFromHeap, lpNSCacheData )
/* NOTE: This proc doesn't deal with the walking pointer */
/* FIXME: Memory leak on data (contained ptrs) */
HeapFree( GetProcessHeap(), 0, elem->data );
HeapFree( GetProcessHeap(), 0, elem->lpNSAddrHdr );
HeapFree( GetProcessHeap(), 0, elem );
free( elem->data );
free( elem->lpNSAddrHdr );
free( elem );
}
/* Render all data in a session cache invalid */
......@@ -260,7 +258,7 @@ void NS_InvalidateSessionCache( LPVOID lpNSInfo )
/* Create and initialize a session cache */
BOOL NS_InitializeSessionCache( LPVOID* lplpNSInfo )
{
lpNSCache lpCache = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *lpCache ) );
lpNSCache lpCache = calloc( 1, sizeof( *lpCache ) );
*lplpNSInfo = lpCache;
......@@ -371,8 +369,7 @@ void NS_ReplyToEnumSessionsRequest( const void *lpcMsg, void **lplpReplyData, DW
*lpdwReplySize = lpDP->dp2->spData.dwSPHeaderSize +
sizeof( *rmsg ) + dwVariableSize;
*lplpReplyData = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
*lpdwReplySize );
*lplpReplyData = calloc( 1, *lpdwReplySize );
rmsg = (LPDPMSG_ENUMSESSIONSREPLY)( (BYTE*)*lplpReplyData +
lpDP->dp2->spData.dwSPHeaderSize);
......
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