Author: fireball
Date: Sun May 21 00:42:26 2006
New Revision: 21955
URL:
http://svn.reactos.ru/svn/reactos?rev=21955&view=rev
Log:
- Slightly update heap-related routines to wine's routines. Doesn't fix regression
tests really, but just in case.
Modified:
trunk/reactos/dll/win32/kernel32/mem/global.c
trunk/reactos/dll/win32/kernel32/mem/heap.c
Modified: trunk/reactos/dll/win32/kernel32/mem/global.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/dll/win32/kernel32/mem/glob…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/mem/global.c (original)
+++ trunk/reactos/dll/win32/kernel32/mem/global.c Sun May 21 00:42:26 2006
@@ -213,13 +213,15 @@
GlobalFree(HGLOBAL hMem)
{
PGLOBAL_HANDLE phandle;
+ HGLOBAL hreturned;
DPRINT("GlobalFree( 0x%lX )\n", (ULONG)hMem);
+ hreturned = 0;
if (ISPOINTER(hMem)) /* POINTER */
{
- RtlFreeHeap(GetProcessHeap(), 0, (PVOID)hMem);
- hMem = 0;
+ if(!RtlFreeHeap(GetProcessHeap(), 0, (PVOID)hMem))
+ hMem = 0;
}
else /* HANDLE */
{
@@ -229,7 +231,8 @@
if(MAGIC_GLOBAL_USED == phandle->Magic)
{
-
+ /* WIN98 does not make this test. That is you can free a */
+ /* block you have not unlocked. Go figure!! */
if(phandle->LockCount!=0)
{
DPRINT1("Warning! GlobalFree(0x%X) Freeing a handle to a locked
object.\n", hMem);
@@ -237,15 +240,17 @@
}
if(phandle->Pointer)
- RtlFreeHeap(GetProcessHeap(), 0, (PVOID)((ULONG_PTR)phandle->Pointer -
HANDLE_SIZE));
-
- RtlFreeHeap(GetProcessHeap(), 0, phandle);
+ if (!RtlFreeHeap(GetProcessHeap(), 0,
(PVOID)((ULONG_PTR)phandle->Pointer - HANDLE_SIZE)))
+ hreturned = hMem;
+
+ if (!RtlFreeHeap(GetProcessHeap(), 0, phandle))
+ hreturned = hMem;
}
HeapUnlock(GetProcessHeap());
hMem = 0;
}
- return hMem;
+ return hreturned;
}
Modified: trunk/reactos/dll/win32/kernel32/mem/heap.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/dll/win32/kernel32/mem/heap…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/mem/heap.c (original)
+++ trunk/reactos/dll/win32/kernel32/mem/heap.c Sun May 21 00:42:26 2006
@@ -40,9 +40,15 @@
*/
HANDLE STDCALL HeapCreate(DWORD flags, DWORD dwInitialSize, DWORD dwMaximumSize)
{
-
+ HANDLE hRet;
DPRINT("HeapCreate( 0x%lX, 0x%lX, 0x%lX )\n", flags, dwInitialSize,
dwMaximumSize);
- return(RtlCreateHeap(flags, NULL, dwMaximumSize, dwInitialSize, NULL, NULL));
+
+ hRet = RtlCreateHeap(flags, NULL, dwMaximumSize, dwInitialSize, NULL, NULL);
+
+ if (!hRet)
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+
+ return hRet;
}
/*********************************************************************