Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
714 B

  1. #include <windows.h>
  2. #include <stdio.h>
  3. #include "memory.h"
  4. static HANDLE hHeap = 0;
  5. BOOL
  6. InitializeHeap(VOID)
  7. {
  8. HANDLE hResult;
  9. hResult = HeapCreate(HEAP_GENERATE_EXCEPTIONS,
  10. HEAP_DEFAULT_SIZE,
  11. 0);
  12. if (0 == hResult) {
  13. return FALSE;
  14. }
  15. hHeap = hResult;
  16. return TRUE;
  17. }
  18. LPVOID
  19. AllocMem(DWORD dwBytes)
  20. {
  21. LPVOID lpResult = 0;
  22. lpResult = HeapAlloc(hHeap,
  23. HEAP_ZERO_MEMORY,
  24. dwBytes);
  25. return lpResult;
  26. }
  27. BOOL
  28. FreeMem(LPVOID lpMem)
  29. {
  30. BOOL bResult = FALSE;
  31. bResult = HeapFree(hHeap,
  32. 0,
  33. lpMem);
  34. return bResult;
  35. }