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.

52 lines
1.1 KiB

  1. #ifndef WIN32_LEAN_AND_MEAN
  2. #define WIN32_LEAN_AND_MEAN
  3. #endif
  4. #include <windows.h>
  5. #include "ccom.h"
  6. #include "memmgr.h"
  7. #ifdef UNDER_CE // Windows CE specific
  8. #include "stub_ce.h" // Windows CE stub for unsupported APIs
  9. #endif // UNDER_CE
  10. #ifdef _DEBUG
  11. static INT allocCount;
  12. static INT allocSize;
  13. static INT freeCount;
  14. static INT freeSize;
  15. #endif
  16. void *CCom::operator new(size_t size)
  17. {
  18. BYTE *p = (BYTE *)MemAlloc(size);
  19. if(p) {
  20. ::ZeroMemory(p, size);
  21. }
  22. #ifdef _DEBUG
  23. allocCount++;
  24. allocSize += (INT)::GlobalSize(GlobalHandle(p));
  25. #endif
  26. return (void *)p;
  27. }
  28. void CCom::operator delete(void *p)
  29. {
  30. #ifdef _DEBUG
  31. allocCount++;
  32. allocSize += (INT)::GlobalSize(GlobalHandle(p));
  33. #endif
  34. if(p) {
  35. MemFree(p);
  36. }
  37. }
  38. #ifdef _DEBUG
  39. VOID PrintMemory(LPSTR lpstrMsg)
  40. {
  41. static CHAR szBuf[512];
  42. //LPSTR lpstr = (lpstrMsg == NULL) ? "none" : lpstrMsg;
  43. wsprintf(szBuf, "%s:Alloc %d size %d Free %d size %d\n",
  44. lpstrMsg,
  45. allocCount, allocSize, freeCount, freeSize);
  46. OutputDebugString(szBuf);
  47. }
  48. #endif