heaph.inc 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. { the next one is for internal use by heap managers only, don't call directly }
  42. { from programs! (JM) }
  43. Function InternSysReAllocMem(var p:pointer;size : longint; var doMove: boolean):pointer;
  44. Function SysReAllocMem(var p:pointer;size:longint):Pointer;
  45. Function Sysmemavail:Longint;
  46. Function Sysmaxavail:Longint;
  47. Function Sysheapsize:longint;
  48. { Tp7 functions }
  49. Procedure Getmem(Var p:pointer;Size:Longint);
  50. Procedure Freemem(Var p:pointer;Size:Longint);
  51. Function memavail:Longint;
  52. Function maxavail:Longint;
  53. { FPC additions }
  54. Function MemSize(p:pointer):Longint;
  55. Function heapsize:longint;
  56. { Delphi functions }
  57. function GetMem(size:longint):pointer;
  58. function Freemem(var p:pointer):longint;
  59. function AllocMem(Size:Longint):pointer;
  60. function ReAllocMem(var p:pointer;Size:Longint):pointer;
  61. { Needed to solve overloading problem with call from assembler (PFV) }
  62. Procedure AsmGetmem(var p:pointer;size:Longint);
  63. Procedure AsmFreemem(var p:pointer);
  64. { Do nothing functions, are only here for tp7 compat }
  65. Procedure mark(var p : pointer);
  66. Procedure release(var p : pointer);
  67. {
  68. $Log$
  69. Revision 1.15 2000-01-20 12:35:35 jonas
  70. * fixed problem with reallocmem and heaptrc
  71. Revision 1.14 2000/01/07 16:41:34 daniel
  72. * copyright 2000
  73. Revision 1.13 2000/01/07 16:32:24 daniel
  74. * copyright 2000 added
  75. Revision 1.12 1999/11/01 13:56:50 peter
  76. * freemem,reallocmem now get var argument
  77. Revision 1.11 1999/10/30 17:39:05 peter
  78. * memorymanager expanded with allocmem/reallocmem
  79. Revision 1.10 1999/09/17 17:14:12 peter
  80. + new heap manager supporting delphi freemem(pointer)
  81. Revision 1.9 1999/05/31 20:36:35 peter
  82. * growing is now 256k or 1mb
  83. Revision 1.8 1999/02/08 09:31:40 florian
  84. * fixed small things regarding TEMPHEAP
  85. Revision 1.7 1998/10/01 14:55:18 peter
  86. + memorymanager like delphi
  87. Revision 1.6 1998/09/08 15:03:27 peter
  88. * moved getmem/freemem/memavail/maxavail to heaph.inc
  89. Revision 1.5 1998/07/02 14:11:30 michael
  90. Reinstated the heapsize function.
  91. Revision 1.3 1998/05/12 10:42:45 peter
  92. * moved getopts to inc/, all supported OS's need argc,argv exported
  93. + strpas, strlen are now exported in the systemunit
  94. * removed logs
  95. * removed $ifdef ver_above
  96. Revision 1.2 1998/04/21 10:23:15 peter
  97. + heapblocks
  98. }