NEWDEL.CPP 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /*
  2. ** Command & Conquer Red Alert(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***************************************************************************
  19. ** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S **
  20. ***************************************************************************
  21. * *
  22. * Project Name : Memory system. *
  23. * *
  24. * File Name : NEWDEL.CPP *
  25. * *
  26. * Programmer : Scott K. Bowen *
  27. * *
  28. * Start Date : June 21, 1994 *
  29. * *
  30. * Last Update : July 17, 1995 [PWG] *
  31. * *
  32. *-------------------------------------------------------------------------*
  33. * Functions: *
  34. * operator NEW -- Overides the global new function. *
  35. * operator delete -- Overides the global delete function. *
  36. * operator NEW[] -- Overides the array version of new. *
  37. * operator delete[] -- Overides the array version of delete[] *
  38. * -- *
  39. * OPERATOR NEW -- New opperator which takes a MEM_FLAG *
  40. * OPERATOR NEW[] -- Global NEW[] which takes MEM_FLAG *
  41. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  42. #include "wwmem.h"
  43. /*=========================================================================*/
  44. /* The following PRIVATE functions are in this file: */
  45. /*=========================================================================*/
  46. /*= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
  47. /***************************************************************************
  48. * OPERATOR NEW -- Overides the global new function. *
  49. * *
  50. * INPUT: *
  51. * *
  52. * OUTPUT: *
  53. * *
  54. * WARNINGS: *
  55. * *
  56. * HISTORY: *
  57. * 06/21/1994 SKB : Created. *
  58. *=========================================================================*/
  59. void * operator new(size_t size)
  60. {
  61. return (Alloc((unsigned long) size, MEM_NEW));
  62. }
  63. /***************************************************************************
  64. * OPERATOR NEW[] -- Overides the array version of new. *
  65. * *
  66. * *
  67. * *
  68. * INPUT: *
  69. * *
  70. * OUTPUT: *
  71. * *
  72. * WARNINGS: *
  73. * *
  74. * HISTORY: *
  75. * 06/21/1994 SKB : Created. *
  76. *=========================================================================*/
  77. void * operator new[](size_t size)
  78. {
  79. return (Alloc((unsigned long) size, MEM_NEW));
  80. }
  81. /***************************************************************************
  82. * OPERATOR NEW -- New opperator which takes a MEM_FLAG *
  83. * *
  84. * *
  85. * *
  86. * INPUT: *
  87. * *
  88. * OUTPUT: *
  89. * *
  90. * WARNINGS: *
  91. * *
  92. * HISTORY: *
  93. * 07/17/1995 PWG : Created. *
  94. *=========================================================================*/
  95. void * operator new(size_t size, MemoryFlagType flag)
  96. {
  97. return(Alloc(size, (MemoryFlagType)(flag|MEM_NEW)));
  98. }
  99. /***************************************************************************
  100. * OPERATOR NEW[] -- Global NEW[] which takes MEM_FLAG *
  101. * *
  102. * INPUT: *
  103. * *
  104. * OUTPUT: *
  105. * *
  106. * WARNINGS: *
  107. * *
  108. * HISTORY: *
  109. * 07/17/1995 PWG : Created. *
  110. *=========================================================================*/
  111. void * operator new[] (size_t size, MemoryFlagType flag)
  112. {
  113. return(Alloc(size, (MemoryFlagType)(flag|MEM_NEW)));
  114. }
  115. /***************************************************************************
  116. * OPERATOR DELETE -- Overides the global delete function. *
  117. * *
  118. * *
  119. * *
  120. * INPUT: *
  121. * *
  122. * OUTPUT: *
  123. * *
  124. * WARNINGS: *
  125. * *
  126. * HISTORY: *
  127. * 06/21/1994 SKB : Created. *
  128. *=========================================================================*/
  129. void operator delete(void *ptr)
  130. {
  131. Free(ptr);
  132. }
  133. /***************************************************************************
  134. * OPERATOR DELETE[] -- Overides the array version of delete[] *
  135. * *
  136. * *
  137. * *
  138. * INPUT: *
  139. * *
  140. * OUTPUT: *
  141. * *
  142. * WARNINGS: *
  143. * *
  144. * HISTORY: *
  145. * 10/20/1994 SKB : Created. *
  146. *=========================================================================*/
  147. void operator delete[](void *ptr)
  148. {
  149. Free(ptr);
  150. }