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.

68 lines
1.7 KiB

  1. /***
  2. *dbgnew.cpp - defines C++ scalar delete routine, debug version
  3. *
  4. * Copyright (c) 1995-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * Defines C++ scalar delete() routine.
  8. *
  9. *Revision History:
  10. * 12-28-95 JWM Split from dbgnew.cpp for granularity.
  11. * 05-22-98 JWM Support for KFrei's RTC work, and operator delete[].
  12. * 07-28-98 JWM RTC update.
  13. * 05-26-99 KBF Updated RTC_Allocate_hook params
  14. * 10-21-99 PML Get rid of delete[], use heap\delete2.cpp for both
  15. * debug and release builds (vs7#53440).
  16. *
  17. *******************************************************************************/
  18. #ifdef _DEBUG
  19. #include <cruntime.h>
  20. #include <malloc.h>
  21. #include <mtdll.h>
  22. #include <dbgint.h>
  23. #include <rtcsup.h>
  24. /***
  25. *void operator delete() - delete a block in the debug heap
  26. *
  27. *Purpose:
  28. * Deletes any type of block.
  29. *
  30. *Entry:
  31. * void *pUserData - pointer to a (user portion) of memory block in the
  32. * debug heap
  33. *
  34. *Return:
  35. * <void>
  36. *
  37. *******************************************************************************/
  38. void operator delete(
  39. void *pUserData
  40. )
  41. {
  42. _CrtMemBlockHeader * pHead;
  43. RTCCALLBACK(_RTC_Free_hook, (pUserData, 0));
  44. if (pUserData == NULL)
  45. return;
  46. _mlock(_HEAP_LOCK); /* block other threads */
  47. /* get a pointer to memory block header */
  48. pHead = pHdr(pUserData);
  49. /* verify block type */
  50. _ASSERTE(_BLOCK_TYPE_IS_VALID(pHead->nBlockUse));
  51. _free_dbg( pUserData, pHead->nBlockUse );
  52. _munlock(_HEAP_LOCK); /* release other threads */
  53. return;
  54. }
  55. #endif /* _DEBUG */