Windows NT 4.0 source code leak
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.

61 lines
1.7 KiB

4 years ago
  1. /***************************************************************************\
  2. * memalloc.c
  3. *
  4. * Copyright (c) 1991 Microsoft Corporation
  5. *
  6. * memory allocation routines for WINMETER
  7. *
  8. * History:
  9. * Written by Hadi Partovi (t-hadip) summer 1991
  10. \***************************************************************************/
  11. #include "winmeter.h"
  12. /***************************************************************************\
  13. * MemAlloc()
  14. *
  15. * Entry: Size to allocate
  16. * Exit: A pointer to new block. If error, it exits the program
  17. \***************************************************************************/
  18. LPVOID MemAlloc(
  19. DWORD dwSize) // size to allocate
  20. {
  21. char *p;
  22. p = (char *) LocalAlloc(LPTR, dwSize);
  23. if (p==NULL) {
  24. ErrorExit(MyLoadString(IDS_OUTOFMEMORY));
  25. }
  26. return (LPVOID) p;
  27. }
  28. /***************************************************************************\
  29. * MemFree()
  30. *
  31. * Entry: a long pointer
  32. * Exit: frees the memory pointed to by the pointer
  33. \***************************************************************************/
  34. void MemFree(
  35. LPVOID ptr) // pointer to memory to release
  36. {
  37. AssertNotNull(ptr);
  38. SetSigBAD(ptr);
  39. LocalFree((LOCALHANDLE)ptr);
  40. return;
  41. }
  42. /***************************************************************************\
  43. * MemReAlloc()
  44. *
  45. * Entry: A pointer to a block, and a Size to Reallocate
  46. * Exit: A pointer to new block. If error, it exits the program
  47. \***************************************************************************/
  48. LPVOID MemReAlloc(
  49. LPVOID p, // pointer to reallocate
  50. DWORD dwSize) // size to reallocate
  51. {
  52. AssertNotNull(p);
  53. MemFree(p);
  54. return MemAlloc(dwSize);
  55. }