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.

72 lines
1.4 KiB

  1. #include "setedit.h" // included by all perfmon sources
  2. #include "pmemory.h" // external declarations for this file
  3. LPMEMORY MemoryAllocate (SIZE_T dwSize)
  4. { // MemoryAllocate
  5. HMEMORY hMemory ;
  6. LPMEMORY lpMemory ;
  7. hMemory = GlobalAlloc (GHND, dwSize) ;
  8. if (!hMemory)
  9. return (NULL) ;
  10. lpMemory = GlobalLock (hMemory) ;
  11. if (!lpMemory)
  12. GlobalFree (hMemory) ;
  13. return (lpMemory) ;
  14. } // MemoryAllocate
  15. VOID MemoryFree (LPMEMORY lpMemory)
  16. { // MemoryFree
  17. HMEMORY hMemory ;
  18. if (!lpMemory)
  19. return ;
  20. hMemory = GlobalHandle (lpMemory) ;
  21. if (hMemory) { // if
  22. GlobalUnlock (hMemory) ;
  23. GlobalFree (hMemory) ;
  24. } // if
  25. } // MemoryFree
  26. SIZE_T MemorySize (LPMEMORY lpMemory)
  27. {
  28. HMEMORY hMemory ;
  29. hMemory = GlobalHandle (lpMemory) ;
  30. if (!hMemory)
  31. return (0L) ;
  32. return (GlobalSize (hMemory)) ;
  33. }
  34. LPMEMORY MemoryResize (LPMEMORY lpMemory,
  35. SIZE_T dwNewSize)
  36. {
  37. HMEMORY hMemory ;
  38. LPMEMORY lpNewMemory ;
  39. hMemory = GlobalHandle (lpMemory) ;
  40. if (!hMemory)
  41. return (NULL) ;
  42. GlobalUnlock (hMemory) ;
  43. hMemory = GlobalReAlloc (hMemory, dwNewSize, GHND) ;
  44. if (!hMemory)
  45. return (NULL) ;
  46. lpNewMemory = GlobalLock (hMemory) ;
  47. return (lpNewMemory) ;
  48. } // MemoryResize