Commit d8aa8535 authored by Dimitrie O. Paun's avatar Dimitrie O. Paun Committed by Alexandre Julliard

Fix the IMalloc::ReAlloc() to follow the documented behavior.

parent cba157e9
......@@ -209,7 +209,12 @@ static LPVOID WINAPI IMalloc_fnRealloc(LPMALLOC iface,LPVOID pv,DWORD cb) {
pv = pRealMemory;
}
pNewMemory = HeapReAlloc(GetProcessHeap(),0,pv,cb);
if (!pv) pNewMemory = HeapAlloc(GetProcessHeap(),0,cb);
else if (cb) pNewMemory = HeapReAlloc(GetProcessHeap(),0,pv,cb);
else {
HeapFree(GetProcessHeap(),0,pv);
pNewMemory = NULL;
}
if(Malloc32.pSpy) {
pNewMemory = IMallocSpy_PostRealloc(Malloc32.pSpy, pNewMemory, TRUE);
......
......@@ -113,28 +113,35 @@ SEGPTR WINAPI IMalloc16_fnAlloc(IMalloc16* iface,DWORD cb) {
}
/******************************************************************************
* IMalloc16_Realloc [COMPOBJ.504]
* IMalloc16_Free [COMPOBJ.505]
*/
SEGPTR WINAPI IMalloc16_fnRealloc(IMalloc16* iface,SEGPTR pv,DWORD cb)
VOID WINAPI IMalloc16_fnFree(IMalloc16* iface,SEGPTR pv)
{
SEGPTR ret;
void *ptr = MapSL(pv);
ICOM_THIS(IMalloc16Impl,iface);
TRACE("(%p)->Realloc(%08lx,%ld)\n",This,pv,cb);
ret = MapLS( HeapReAlloc( GetProcessHeap(), 0, MapSL(pv), cb ) );
TRACE("(%p)->Free(%08lx)\n",This,pv);
UnMapLS(pv);
return ret;
HeapFree( GetProcessHeap(), 0, ptr );
}
/******************************************************************************
* IMalloc16_Free [COMPOBJ.505]
* IMalloc16_Realloc [COMPOBJ.504]
*/
VOID WINAPI IMalloc16_fnFree(IMalloc16* iface,SEGPTR pv)
SEGPTR WINAPI IMalloc16_fnRealloc(IMalloc16* iface,SEGPTR pv,DWORD cb)
{
void *ptr = MapSL(pv);
SEGPTR ret;
ICOM_THIS(IMalloc16Impl,iface);
TRACE("(%p)->Free(%08lx)\n",This,pv);
TRACE("(%p)->Realloc(%08lx,%ld)\n",This,pv,cb);
if (!pv)
ret = IMalloc16_fnAlloc(iface, cb);
else if (cb) {
ret = MapLS( HeapReAlloc( GetProcessHeap(), 0, MapSL(pv), cb ) );
UnMapLS(pv);
HeapFree( GetProcessHeap(), 0, ptr );
} else {
IMalloc16_fnFree(iface, pv);
ret = 0;
}
return ret;
}
/******************************************************************************
......
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