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.

112 lines
1.3 KiB

4 years ago
  1. /*++
  2. Copyright (c) 1993 Microsoft Corporation
  3. Module Name:
  4. bkmem.c
  5. Abstract:
  6. Memory allocation routines for online books program
  7. Author:
  8. Ted Miller (tedm) 5-Jan-1995
  9. Revision History:
  10. --*/
  11. #include "books.h"
  12. VOID
  13. OutOfMemory(
  14. VOID
  15. )
  16. /*++
  17. Routine Description:
  18. Display an out of memory message box and terminate.
  19. Arguments:
  20. None.
  21. Return Value:
  22. THIS ROUTINE DOES NOT RETURN TO ITS CALLER
  23. --*/
  24. {
  25. MessageBox(hInst,L"OOM",NULL,MB_OK); // BUGBUG
  26. ExitProcess(1);
  27. }
  28. PVOID
  29. MyMalloc(
  30. IN DWORD Size
  31. )
  32. /*++
  33. Routine Description:
  34. Allocate a zeroed-out block of memory.
  35. If allocation fails this routine does not return.
  36. Arguments:
  37. Size - supplies the number of bytes of memory required.
  38. The memory block can be freed with MyFree when no
  39. longer needed.
  40. Return Value:
  41. Pointer to buffer of the requested size. The buffer will
  42. be zeroed out.
  43. --*/
  44. {
  45. PVOID p = (PVOID)LocalAlloc(LPTR,Size);
  46. if(!p) {
  47. OutOfMemory();
  48. }
  49. return(p);
  50. }
  51. VOID
  52. MyFree(
  53. IN PVOID Block
  54. )
  55. /*++
  56. Routine Description:
  57. Free a block of memory previously alocated by MyMalloc.
  58. Arguments:
  59. Block - supplied pointer to block of memory to be freed.
  60. Return Value:
  61. None.
  62. --*/
  63. {
  64. LocalFree((HLOCAL)Block);
  65. }