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.

84 lines
3.9 KiB

  1. #ifndef _NEW_HPP_
  2. #define _NEW_HPP_
  3. // Ruler
  4. // 1 2 3 4 5 6 7 8
  5. //345678901234567890123456789012345678901234567890123456789012345678901234567890
  6. /********************************************************************/
  7. /* */
  8. /* The standard layout. */
  9. /* */
  10. /* The standard layout for 'hpp' files for this code is as */
  11. /* follows: */
  12. /* */
  13. /* 1. Include files. */
  14. /* 2. Constants exported from the class. */
  15. /* 3. Data structures exported from the class. */
  16. /* 4. Forward references to other data structures. */
  17. /* 5. Class specifications (including inline functions). */
  18. /* 6. Additional large inline functions. */
  19. /* */
  20. /* Any portion that is not required is simply omitted. */
  21. /* */
  22. /********************************************************************/
  23. #include "Global.hpp"
  24. #ifdef ENABLE_GLOBAL_ROCKALL
  25. #include "DefaultHeap.hpp"
  26. #endif
  27. /********************************************************************/
  28. /* */
  29. /* The placement new and delete macros. */
  30. /* */
  31. /* The placement new and delete macros allow the constructor */
  32. /* and destructos of a type to be called as needed. */
  33. /* */
  34. /********************************************************************/
  35. #define PLACEMENT_NEW( Address,Type ) new( Address ) Type
  36. #define PLACEMENT_DELETE( Address,Type ) (((Type*) Address) -> ~Type())
  37. #ifndef DISABLE_GLOBAL_NEW
  38. /********************************************************************/
  39. /* */
  40. /* The memory allocation operator. */
  41. /* */
  42. /* The memory allocation operator 'new' is overloaded to */
  43. /* provide a consistent interface. */
  44. /* */
  45. /********************************************************************/
  46. INLINE VOID *operator new( size_t Size )
  47. {
  48. #ifdef ENABLE_GLOBAL_ROCKALL
  49. REGISTER VOID *Store = DefaultHeap.New( Size );
  50. #else
  51. REGISTER VOID *Store = malloc( Size );
  52. #endif
  53. if ( Store == NULL )
  54. { Failure( "Out of system memory" ); }
  55. return Store;
  56. }
  57. /********************************************************************/
  58. /* */
  59. /* The memory deallocation operator. */
  60. /* */
  61. /* The memory deallocation operator releases allocated memory. */
  62. /* */
  63. /********************************************************************/
  64. INLINE VOID operator delete( VOID *Store )
  65. {
  66. #ifdef ENABLE_GLOBAL_ROCKALL
  67. DefaultHeap.Delete( Store );
  68. #else
  69. free( Store );
  70. #endif
  71. }
  72. #endif
  73. #endif