memtracecpp.h 956 B

1234567891011121314151617181920212223242526272829303132
  1. #ifndef _TOOLKIT_MEMORY_TRACE_CPP_H__
  2. #define _TOOLKIT_MEMORY_TRACE_CPP_H__
  3. #include "memutil.h"
  4. inline void* operator new(std::size_t size) throw (std::bad_alloc) {
  5. void* ptr = malloc(size);
  6. if (ptr == NULL) throw std::bad_alloc();
  7. return ptr;
  8. }
  9. inline void* operator new[](std::size_t size) throw (std::bad_alloc) {
  10. void* ptr = malloc(size);
  11. if (ptr == NULL) throw std::bad_alloc();
  12. return ptr;
  13. }
  14. inline void operator delete (void* ptr) throw() { free(ptr); }
  15. inline void operator delete[](void* ptr) throw() { free(ptr); }
  16. inline void* operator new(std::size_t size, const std::nothrow_t&) throw() {
  17. return malloc(size);
  18. }
  19. inline void* operator new[](std::size_t size,
  20. const std::nothrow_t&) throw() {
  21. return malloc(size);
  22. }
  23. inline void operator delete(void* ptr, const std::nothrow_t&) throw() {
  24. free(ptr);
  25. }
  26. inline void operator delete[](void* ptr, const std::nothrow_t&) throw() {
  27. free(ptr);
  28. }
  29. #endif /*_TOOLKIT_MEMORY_TRACE_CPP_H__*/