heaph.inc 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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 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.14 2000-01-07 16:41:34 daniel
  67. * copyright 2000
  68. Revision 1.13 2000/01/07 16:32:24 daniel
  69. * copyright 2000 added
  70. Revision 1.12 1999/11/01 13:56:50 peter
  71. * freemem,reallocmem now get var argument
  72. Revision 1.11 1999/10/30 17:39:05 peter
  73. * memorymanager expanded with allocmem/reallocmem
  74. Revision 1.10 1999/09/17 17:14:12 peter
  75. + new heap manager supporting delphi freemem(pointer)
  76. Revision 1.9 1999/05/31 20:36:35 peter
  77. * growing is now 256k or 1mb
  78. Revision 1.8 1999/02/08 09:31:40 florian
  79. * fixed small things regarding TEMPHEAP
  80. Revision 1.7 1998/10/01 14:55:18 peter
  81. + memorymanager like delphi
  82. Revision 1.6 1998/09/08 15:03:27 peter
  83. * moved getmem/freemem/memavail/maxavail to heaph.inc
  84. Revision 1.5 1998/07/02 14:11:30 michael
  85. Reinstated the heapsize function.
  86. Revision 1.3 1998/05/12 10:42:45 peter
  87. * moved getopts to inc/, all supported OS's need argc,argv exported
  88. + strpas, strlen are now exported in the systemunit
  89. * removed logs
  90. * removed $ifdef ver_above
  91. Revision 1.2 1998/04/21 10:23:15 peter
  92. + heapblocks
  93. }