sharemem.pp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2006 by the Free Pascal development team.
  4. Shared memory manager
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. unit sharemem;
  12. interface
  13. implementation
  14. const
  15. fpcmemdll = 'fpcmemdll.dll';
  16. function SysGetmem(Size:ptruint):Pointer;external fpcmemdll;
  17. function SysFreemem(p:pointer):ptruint;external fpcmemdll;
  18. function SysFreememSize(p:pointer;Size:ptruint):ptruint;external fpcmemdll;
  19. function SysAllocMem(size:ptruint):Pointer;external fpcmemdll;
  20. function SysReAllocMem(var p:pointer;size:ptruint):Pointer;external fpcmemdll;
  21. function SysMemSize(p:pointer):ptruint;external fpcmemdll;
  22. function SysGetHeapStatus:THeapStatus;external fpcmemdll;
  23. function SysGetFPCHeapStatus:TFPCHeapStatus;external fpcmemdll;
  24. var
  25. MemoryManager: TMemoryManager = (
  26. NeedLock: true;
  27. GetMem: nil;
  28. FreeMem: nil;
  29. FreeMemSize: nil;
  30. AllocMem: nil;
  31. ReAllocMem: nil;
  32. MemSize: nil;
  33. InitThread: nil;
  34. DoneThread: nil;
  35. RelocateHeap: nil;
  36. GetHeapStatus: nil;
  37. GetFPCHeapStatus: nil;
  38. );
  39. begin
  40. with MemoryManager do
  41. begin
  42. GetMem:=@SysGetmem;
  43. FreeMem:=@SysFreeMem;
  44. FreeMemSize:=@SysFreeMemSize;
  45. AllocMem:=@SysAllocMem;
  46. ReAllocMem:=@SysReAllocMem;
  47. MemSize:=@SysMemSize;
  48. GetHeapStatus:=@SysGetHeapStatus;
  49. GetFPCHeapStatus:=@SysGetFPCHeapStatus;
  50. end;
  51. SetMemoryManager(MemoryManager);
  52. end.