heaph.inc 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1993,97 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 SysReAllocMem(var p:pointer;size:longint):Pointer;
  42. Function Sysmemavail:Longint;
  43. Function Sysmaxavail:Longint;
  44. Function Sysheapsize:longint;
  45. { Tp7 functions }
  46. Procedure Getmem(Var p:pointer;Size:Longint);
  47. Procedure Freemem(Var p:pointer;Size:Longint);
  48. Function memavail:Longint;
  49. Function maxavail:Longint;
  50. { FPC additions }
  51. Function MemSize(p:pointer):Longint;
  52. Function heapsize:longint;
  53. { Delphi functions }
  54. function GetMem(size:longint):pointer;
  55. function Freemem(var p:pointer):longint;
  56. function AllocMem(Size:Longint):pointer;
  57. function ReAllocMem(var p:pointer;Size:Longint):pointer;
  58. { Needed to solve overloading problem with call from assembler (PFV) }
  59. Procedure AsmGetmem(var p:pointer;size:Longint);
  60. Procedure AsmFreemem(var p:pointer);
  61. { Do nothing functions, are only here for tp7 compat }
  62. Procedure mark(var p : pointer);
  63. Procedure release(var p : pointer);
  64. {
  65. $Log$
  66. Revision 1.12 1999-11-01 13:56:50 peter
  67. * freemem,reallocmem now get var argument
  68. Revision 1.11 1999/10/30 17:39:05 peter
  69. * memorymanager expanded with allocmem/reallocmem
  70. Revision 1.10 1999/09/17 17:14:12 peter
  71. + new heap manager supporting delphi freemem(pointer)
  72. Revision 1.9 1999/05/31 20:36:35 peter
  73. * growing is now 256k or 1mb
  74. Revision 1.8 1999/02/08 09:31:40 florian
  75. * fixed small things regarding TEMPHEAP
  76. Revision 1.7 1998/10/01 14:55:18 peter
  77. + memorymanager like delphi
  78. Revision 1.6 1998/09/08 15:03:27 peter
  79. * moved getmem/freemem/memavail/maxavail to heaph.inc
  80. Revision 1.5 1998/07/02 14:11:30 michael
  81. Reinstated the heapsize function.
  82. Revision 1.3 1998/05/12 10:42:45 peter
  83. * moved getopts to inc/, all supported OS's need argc,argv exported
  84. + strpas, strlen are now exported in the systemunit
  85. * removed logs
  86. * removed $ifdef ver_above
  87. Revision 1.2 1998/04/21 10:23:15 peter
  88. + heapblocks
  89. }