sysheap.inc 1.9 KB

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