heaph.inc 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2000 by the Free Pascal development team
  5. Heap manager interface section
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. { Memorymanager }
  13. type
  14. PMemoryManager = ^TMemoryManager;
  15. TMemoryManager = record
  16. Getmem : Function(Size:Longint):Pointer;
  17. Freemem : Function(var p:pointer):Longint;
  18. FreememSize : Function(var p:pointer;Size:Longint):Longint;
  19. AllocMem : Function(Size:longint):Pointer;
  20. ReAllocMem : Function(var p:pointer;Size:longint):Pointer;
  21. MemSize : function(p:pointer):Longint;
  22. MemAvail : Function:Longint;
  23. MaxAvail : Function:Longint;
  24. HeapSize : Function:Longint;
  25. end;
  26. procedure GetMemoryManager(var MemMgr: TMemoryManager);
  27. procedure SetMemoryManager(const MemMgr: TMemoryManager);
  28. function IsMemoryManagerSet: Boolean;
  29. { Variables }
  30. const
  31. growheapsize1 : longint=256*1024; { < 256k will grow with 256k }
  32. growheapsize2 : longint=1024*1024; { > 256k will grow with 1m }
  33. var
  34. heaporg,heapptr,heapend,heaperror,freelist : pointer;
  35. { Default MemoryManager functions }
  36. Function SysGetmem(Size:Longint):Pointer;
  37. Function SysFreemem(var p:pointer):Longint;
  38. Function SysFreememSize(var p:pointer;Size:Longint):Longint;
  39. Function SysMemSize(p:pointer):Longint;
  40. Function SysAllocMem(size:longint):Pointer;
  41. function SysTryResizeMem(var p:pointer;size : longint):boolean;
  42. Function SysReAllocMem(var p:pointer;size:longint):Pointer;
  43. Function Sysmemavail:Longint;
  44. Function Sysmaxavail:Longint;
  45. Function Sysheapsize:longint;
  46. { Tp7 functions }
  47. Procedure Getmem(Var p:pointer;Size:Longint);
  48. Procedure Freemem(Var p:pointer;Size:Longint);
  49. Function memavail:Longint;
  50. Function maxavail:Longint;
  51. { FPC additions }
  52. Function MemSize(p:pointer):Longint;
  53. Function heapsize:longint;
  54. { Delphi functions }
  55. function GetMem(size:longint):pointer;
  56. function Freemem(var p:pointer):longint;
  57. function AllocMem(Size:Longint):pointer;
  58. function ReAllocMem(var p:pointer;Size:Longint):pointer;
  59. { Needed to solve overloading problem with call from assembler (PFV) }
  60. Procedure AsmGetmem(var p:pointer;size:Longint);
  61. Procedure AsmFreemem(var p:pointer);
  62. { Do nothing functions, are only here for tp7 compat }
  63. Procedure mark(var p : pointer);
  64. Procedure release(var p : pointer);
  65. {
  66. $Log$
  67. Revision 1.17 2000-02-09 16:59:30 peter
  68. * truncated log
  69. Revision 1.16 2000/01/31 23:41:30 peter
  70. * reallocmem fixed for freemem() call when size=0
  71. Revision 1.15 2000/01/20 12:35:35 jonas
  72. * fixed problem with reallocmem and heaptrc
  73. Revision 1.14 2000/01/07 16:41:34 daniel
  74. * copyright 2000
  75. Revision 1.13 2000/01/07 16:32:24 daniel
  76. * copyright 2000 added
  77. Revision 1.12 1999/11/01 13:56:50 peter
  78. * freemem,reallocmem now get var argument
  79. Revision 1.11 1999/10/30 17:39:05 peter
  80. * memorymanager expanded with allocmem/reallocmem
  81. Revision 1.10 1999/09/17 17:14:12 peter
  82. + new heap manager supporting delphi freemem(pointer)
  83. }