Source code of Windows XP (NT5)
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.

101 lines
1.9 KiB

  1. /*++
  2. Copyright (c) 1999-2000 Microsoft Corporation
  3. Module Name:
  4. RemoteDesktopDBG
  5. Abstract:
  6. Contains Debug Routines for RD
  7. Author:
  8. Tad Brockway 02/00
  9. Revision History:
  10. --*/
  11. #ifndef __REMOTEDESKTOPDBG_H__
  12. #define __REMOTEDESKTOPDBG_H__
  13. //
  14. // Route ASSERT to TRC_ASSERT.
  15. //
  16. #undef ASSERT
  17. #if DBG
  18. #define ASSERT(expr) if (!(expr)) \
  19. { TRC_ERR((TB, L"Failure at Line %d in %s\n",__LINE__, TEXT##(__FILE__))); \
  20. DebugBreak(); }
  21. #else
  22. #define ASSERT(expr)
  23. #endif
  24. //
  25. // Object and Memory Tracking Defines
  26. //
  27. #define GOODMEMMAGICNUMBER 0x07052530
  28. #define REMOTEDESKTOPBADMEM 0xCF
  29. #define UNITIALIZEDMEM 0xCC
  30. #define FREEDMEMMAGICNUMBER 0x09362229
  31. //
  32. // Memory Allocation Tags
  33. //
  34. #define REMOTEDESKTOPOBJECT_TAG ('BOHS')
  35. #define REMOTEDESKTOPGLOBAL_TAG ('BGHS')
  36. ////////////////////////////////////////////////////////////
  37. //
  38. // Memory Allocation Routines
  39. //
  40. #if DBG
  41. //
  42. // The Functions
  43. //
  44. #ifdef __cplusplus
  45. extern "C" {
  46. #endif
  47. void *RemoteDesktopAllocateMem(size_t size, DWORD tag);
  48. void RemoteDesktopFreeMem(void *ptr);
  49. void *RemoteDesktopReallocMem(void *ptr, size_t sz);
  50. #ifdef __cplusplus
  51. }
  52. #endif
  53. //
  54. // The C++ Operators
  55. //
  56. #if defined(__cplusplus) && defined(DEBUGMEM)
  57. inline void *__cdecl operator new(size_t sz)
  58. {
  59. void *ptr = RemoteDesktopAllocateMem(sz, REMOTEDESKTOPGLOBAL_TAG);
  60. return ptr;
  61. }
  62. inline void *__cdecl operator new(size_t sz, DWORD tag)
  63. {
  64. void *ptr = RemoteDesktopAllocateMem(sz, tag);
  65. return ptr;
  66. }
  67. inline void __cdecl operator delete(void *ptr)
  68. {
  69. RemoteDesktopFreeMem(ptr);
  70. }
  71. #endif
  72. #define ALLOCMEM(size) RemoteDesktopAllocateMem(size, REMOTEDESKTOPGLOBAL_TAG)
  73. #define FREEMEM(ptr) RemoteDesktopFreeMem(ptr)
  74. #define REALLOCMEM(ptr, sz) RemoteDesktopReallocMem(ptr, sz)
  75. #else
  76. #define ALLOCMEM(size) malloc(size)
  77. #define FREEMEM(ptr) free(ptr)
  78. #define REALLOCMEM(ptr, sz) realloc(ptr, sz)
  79. #endif
  80. #endif //__REMOTEDESKTOPDBG_H__