Advertisement
Guest User

Untitled

a guest
May 20th, 2012
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.12 KB | None | 0 0
  1. --- MINIMAL.H ---
  2.  
  3. #ifndef _MINIMAL_H
  4. #define _MINIMAL_H
  5.  
  6. #include <iostream>
  7.  
  8. #ifdef _DEBUG
  9.  
  10. void* operator new(size_t Size, int Line, const char* File);
  11. void* operator new[](size_t Size, int Line, const char* File);
  12.  
  13. void operator delete(void* ptr, int Line, const char* File);
  14. void operator delete[](void* ptr, int Line, const char* File);
  15.  
  16. #endif
  17.  
  18. #ifdef _DEBUG
  19.  
  20. #define DEBUG_NEW new(__LINE__,__FILE__)
  21.  
  22. #else
  23.  
  24. #define DEBUG_NEW new
  25.  
  26. #endif
  27.  
  28.  
  29.  
  30. #endif //_MINIMAL_H
  31.  
  32.  
  33. --- MINIMAL.CPP ---
  34.  
  35. #include "Minimal.h"
  36.  
  37. #define new DEBUG_NEW
  38.  
  39. #ifdef _DEBUG
  40.  
  41. void* operator new(size_t Size, int Line, const char* File)
  42. {
  43.     void* ptr = (void*)malloc(Size);
  44.  
  45.     if(ptr)
  46.     {
  47.         return ptr;
  48.     };
  49. };
  50.  
  51. void* operator new[](size_t Size, int Line, const char* File)
  52. {
  53.     void* ptr = (void*)malloc(Size);
  54.  
  55.     if(ptr)
  56.     {
  57.         return ptr;
  58.     };
  59. };
  60.  
  61. void operator delete(void* ptr, int Line, const char* File)
  62. {
  63.     if(ptr)
  64.     {
  65.         free(ptr);
  66.     }
  67.     else
  68.     {
  69.         return;
  70.     };
  71. };
  72.  
  73. void operator delete[](void* ptr, int Line, const char* File)
  74. {
  75.     if(ptr)
  76.     {
  77.         free(ptr);
  78.     }
  79.     else
  80.     {
  81.         return;
  82.     };
  83. };
  84.  
  85. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement