sharemem.pp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. {$IFNDEF FPC_DOTTEDUNITS}
  12. unit sharemem;
  13. {$ENDIF FPC_DOTTEDUNITS}
  14. interface
  15. implementation
  16. const
  17. fpcmemdll = 'fpcmemdll.dll';
  18. function SysGetmem(Size:ptruint):Pointer;external fpcmemdll;
  19. function SysFreemem(p:pointer):ptruint;external fpcmemdll;
  20. function SysFreememSize(p:pointer;Size:ptruint):ptruint;external fpcmemdll;
  21. function SysAllocMem(size:ptruint):Pointer;external fpcmemdll;
  22. function SysReAllocMem(var p:pointer;size:ptruint):Pointer;external fpcmemdll;
  23. function SysMemSize(p:pointer):ptruint;external fpcmemdll;
  24. function SysGetHeapStatus:THeapStatus;external fpcmemdll;
  25. function SysGetFPCHeapStatus:TFPCHeapStatus;external fpcmemdll;
  26. var
  27. MemoryManager: TMemoryManager = (
  28. NeedLock: true;
  29. GetMem: nil;
  30. FreeMem: nil;
  31. FreeMemSize: nil;
  32. AllocMem: nil;
  33. ReAllocMem: nil;
  34. MemSize: nil;
  35. InitThread: nil;
  36. DoneThread: nil;
  37. RelocateHeap: nil;
  38. GetHeapStatus: nil;
  39. GetFPCHeapStatus: nil;
  40. );
  41. begin
  42. with MemoryManager do
  43. begin
  44. GetMem:=@SysGetmem;
  45. FreeMem:=@SysFreeMem;
  46. FreeMemSize:=@SysFreeMemSize;
  47. AllocMem:=@SysAllocMem;
  48. ReAllocMem:=@SysReAllocMem;
  49. MemSize:=@SysMemSize;
  50. GetHeapStatus:=@SysGetHeapStatus;
  51. GetFPCHeapStatus:=@SysGetFPCHeapStatus;
  52. end;
  53. SetMemoryManager(MemoryManager);
  54. end.