OSDN Git Service

GlobalAlloc系APIでないとダメらしい。
authorC.Ponapalt <ponapalt@shillest.net>
Sat, 11 Dec 2004 11:18:37 +0000 (11:18 +0000)
committerC.Ponapalt <ponapalt@shillest.net>
Sat, 11 Dec 2004 11:18:37 +0000 (11:18 +0000)
bottleclient/SimpleMemoryManager.pas

index 3e4d926..f68963f 100644 (file)
@@ -9,23 +9,21 @@ uses Windows, SysUtils;
 implementation
 
 var
-  hProcessHeap: Cardinal;
   OldMemMgr: TMemoryManager;
 
 function NewGetMem(Size: Integer): Pointer;
 begin
-  Result := HeapAlloc(hProcessHeap,0,Size);
+  Result := Pointer(GlobalAlloc(GMEM_FIXED,Size));
 end;
 
 function NewFreeMem(P: Pointer): Integer;
 begin
-  if HeapFree(hProcessHeap,0,P) then Result := 0
-  else Result := 1;
+  Result := GlobalFree(HGLOBAL(P));
 end;
 
 function NewReallocMem(P: Pointer; Size: Integer): Pointer;
 begin
-  Result := HeapRealloc(hProcessHeap,0,P,Size);
+  Result := Pointer(GlobalReAlloc(HGLOBAL(P),Size,GMEM_MOVEABLE));
 end;
 
 const
@@ -35,8 +33,6 @@ const
   ReallocMem: NewReallocMem);
 
 initialization
-  hProcessHeap := GetProcessHeap();
-
   GetMemoryManager(OldMemMgr);
   SetMemoryManager(NewMemMgr);