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

This commit is contained in:
Dimitrie O. Paun 2003-11-26 03:34:51 +00:00 committed by Alexandre Julliard
parent cba157e998
commit d8aa853596
2 changed files with 26 additions and 14 deletions

View File

@ -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);

View File

@ -112,19 +112,6 @@ SEGPTR WINAPI IMalloc16_fnAlloc(IMalloc16* iface,DWORD cb) {
return MapLS( HeapAlloc( GetProcessHeap(), 0, cb ) );
}
/******************************************************************************
* IMalloc16_Realloc [COMPOBJ.504]
*/
SEGPTR WINAPI IMalloc16_fnRealloc(IMalloc16* iface,SEGPTR pv,DWORD cb)
{
SEGPTR ret;
ICOM_THIS(IMalloc16Impl,iface);
TRACE("(%p)->Realloc(%08lx,%ld)\n",This,pv,cb);
ret = MapLS( HeapReAlloc( GetProcessHeap(), 0, MapSL(pv), cb ) );
UnMapLS(pv);
return ret;
}
/******************************************************************************
* IMalloc16_Free [COMPOBJ.505]
*/
@ -137,6 +124,26 @@ VOID WINAPI IMalloc16_fnFree(IMalloc16* iface,SEGPTR pv)
HeapFree( GetProcessHeap(), 0, ptr );
}
/******************************************************************************
* IMalloc16_Realloc [COMPOBJ.504]
*/
SEGPTR WINAPI IMalloc16_fnRealloc(IMalloc16* iface,SEGPTR pv,DWORD cb)
{
SEGPTR ret;
ICOM_THIS(IMalloc16Impl,iface);
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);
} else {
IMalloc16_fnFree(iface, pv);
ret = 0;
}
return ret;
}
/******************************************************************************
* IMalloc16_GetSize [COMPOBJ.506]
*/