sysheap.inc 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2001 by Free Pascal development team
  4. This file implements all the base types and limits required
  5. for a minimal POSIX compliant subset required to port the compiler
  6. to a new OS.
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. {*****************************************************************************
  14. OS Memory allocation / deallocation
  15. ****************************************************************************}
  16. { memory functions }
  17. function GetProcessHeap : DWord;
  18. stdcall;external 'kernel32' name 'GetProcessHeap';
  19. function HeapAlloc(hHeap : DWord; dwFlags : DWord; dwBytes : DWord) : Longint;
  20. stdcall;external 'kernel32' name 'HeapAlloc';
  21. function HeapFree(hHeap : dword; dwFlags : dword; lpMem: pointer) : boolean;
  22. stdcall;external 'kernel32' name 'HeapFree';
  23. {$IFDEF SYSTEMDEBUG}
  24. function WinAPIHeapSize(hHeap : DWord; dwFlags : DWord; ptr : Pointer) : DWord;
  25. stdcall;external 'kernel32' name 'HeapSize';
  26. {$ENDIF}
  27. function SysOSAlloc(size: ptrint): pointer;
  28. var
  29. l : longword;
  30. begin
  31. l := HeapAlloc(GetProcessHeap, 0, size);
  32. {$ifdef DUMPGROW}
  33. Writeln('new heap part at $',hexstr(l,8), ' size = ',WinAPIHeapSize(GetProcessHeap()));
  34. {$endif}
  35. SysOSAlloc := pointer(l);
  36. end;
  37. {$define HAS_SYSOSFREE}
  38. procedure SysOSFree(p: pointer; size: ptrint);
  39. begin
  40. HeapFree(GetProcessHeap, 0, p);
  41. end;