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.

86 lines
2.1 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: dbmem.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. /*----------------------------------------------------------------------------
  11. / Title;
  12. / dbmem.cpp
  13. /
  14. / Authors;
  15. / David De Vorchik (daviddv)
  16. /
  17. / Notes;
  18. / Wrappers for memory allocation (for tracking leaks etc)
  19. /----------------------------------------------------------------------------*/
  20. #include "precomp.hxx"
  21. #include "stdio.h"
  22. #pragma hdrstop
  23. #ifdef DEBUG
  24. /*-----------------------------------------------------------------------------
  25. / Locals & helper functions
  26. /----------------------------------------------------------------------------*/
  27. // Ensure that we don't recurse
  28. #undef LocalAlloc
  29. #undef LocalFree
  30. /*-----------------------------------------------------------------------------
  31. / DebugLocalAlloc
  32. / ---------------
  33. / Perform a LocalAlloc with suitable tracking of the block.
  34. /
  35. / In:
  36. / uFlags = flags
  37. / cbSize = size of allocation
  38. /
  39. / Out:
  40. / HLOCAL
  41. /----------------------------------------------------------------------------*/
  42. HLOCAL DebugLocalAlloc(UINT uFlags, SIZE_T cbSize)
  43. {
  44. HLOCAL hResult;
  45. TraceEnter(TRACE_COMMON_MEMORY, "DebugLocalAlloc");
  46. Trace(TEXT("Flags %08x, Size %d (%08x)"), uFlags, cbSize, cbSize);
  47. hResult = LocalAlloc(uFlags, cbSize);
  48. TraceLeaveValue(hResult);
  49. }
  50. /*-----------------------------------------------------------------------------
  51. / DebugLocalFree
  52. / --------------
  53. / Wrapper for local free that releases the memory allocation.
  54. /
  55. / In:
  56. / hLocal = allocation to be free'd
  57. /
  58. / Out:
  59. / HLOCAL
  60. /----------------------------------------------------------------------------*/
  61. HLOCAL DebugLocalFree(HLOCAL hLocal)
  62. {
  63. HLOCAL hResult;
  64. TraceEnter(TRACE_COMMON_MEMORY, "DebugLocalAlloc");
  65. Trace(TEXT("Freeing handle %08x"), hLocal);
  66. hResult = LocalFree(hLocal);
  67. TraceLeaveValue(hResult);
  68. }
  69. #endif // DEBUG