Leaked source code of windows server 2003
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.

77 lines
1.1 KiB

  1. #include "fdisk.h"
  2. #include <malloc.h>
  3. #include <process.h>
  4. PVOID
  5. Malloc(
  6. IN ULONG Size
  7. )
  8. {
  9. PVOID p;
  10. while((p = malloc(Size)) == NULL) {
  11. ConfirmOutOfMemory();
  12. }
  13. return(p);
  14. }
  15. PVOID
  16. Realloc(
  17. IN PVOID Block,
  18. IN ULONG NewSize
  19. )
  20. {
  21. PVOID p;
  22. if(NewSize) {
  23. while((p = realloc(Block,NewSize)) == NULL) {
  24. ConfirmOutOfMemory();
  25. }
  26. } else {
  27. //
  28. // realloc with a size of 0 is the same as free,
  29. // so special case that here.
  30. //
  31. free(Block);
  32. while((p = malloc(0)) == NULL) {
  33. ConfirmOutOfMemory();
  34. }
  35. }
  36. return(p);
  37. }
  38. VOID
  39. Free(
  40. IN PVOID Block
  41. )
  42. {
  43. free(Block);
  44. }
  45. VOID
  46. ConfirmOutOfMemory(
  47. VOID
  48. )
  49. {
  50. va_list arglist =
  51. #ifdef _ALPHA_
  52. {0}; // Alpha defines va_list as a struct. Init as such.
  53. #else
  54. NULL;
  55. #endif
  56. if(CommonDialog(MSG_OUT_OF_MEMORY,
  57. NULL,
  58. MB_ICONHAND | MB_RETRYCANCEL | MB_SYSTEMMODAL,
  59. arglist) != IDRETRY) {
  60. exit(1);
  61. }
  62. }