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.

70 lines
1.3 KiB

  1. /*----------------------------------------------------------------------------
  2. dbgtrace.c
  3. Debug trace functions.
  4. Copyright (C) Microsoft Corporation, 1993 - 1998
  5. All rights reserved.
  6. Authors:
  7. suryanr Suryanarayanan Raman
  8. GaryBu Gary S. Burd
  9. History:
  10. 05/11/93 suryanr Created
  11. 06/18/93 GaryBu Convert to C.
  12. 07/21/93 KennT Code Reorg
  13. 07/26/94 SilvanaR Trace Buffer
  14. 27 oct 95 garykac DBCS_FILE_CHECK debug file: BEGIN_STRING_OK
  15. ----------------------------------------------------------------------------*/
  16. #include "stdafx.h"
  17. #include <string.h>
  18. #include <stdio.h>
  19. #include <stdarg.h>
  20. #include <time.h>
  21. #include <stdarg.h>
  22. #include <tchar.h>
  23. #include "new"
  24. #include "dbgutil.h"
  25. #ifdef _DEBUG
  26. #define new DEBUG_NEW
  27. #undef THIS_FILE
  28. static char THIS_FILE[] = __FILE__;
  29. #endif
  30. static const std::bad_alloc nomem;
  31. void * TFSAlloc(size_t size)
  32. {
  33. void* ptr = 0;
  34. // NOTE: if someone calls _set_new_mode(1), then were hosed, as that
  35. // will cause malloc to call the new handler were trying to avoid!
  36. ptr = malloc(size);
  37. if (ptr == NULL)
  38. {
  39. ::OutputDebugString(
  40. TEXT("myOperatorNew: user opted to throw bad_alloc\n"));
  41. throw nomem;
  42. }
  43. #ifdef DEBUG_BUILD
  44. memset(ptr, 0xCD, size);
  45. #endif
  46. return ptr;
  47. }
  48. void TFSFree(void* ptr)
  49. {
  50. free(ptr);
  51. }