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.

77 lines
2.5 KiB

  1. /*===================================================================
  2. Microsoft Denali
  3. Microsoft Confidential.
  4. Copyright 1996 Microsoft Corporation. All Rights Reserved.
  5. Component: Memory Management
  6. File: Memchk.h
  7. Owner: PramodD
  8. This is the Memory Manager header file
  9. ===================================================================*/
  10. #ifndef MEMCHK_H
  11. #define MEMCHK_H
  12. #define DENALI_MEMCHK
  13. // Always use these macros, DO NOT ever use DenaliMemXX functions directly
  14. // Function names that SHOULD BE used
  15. #define malloc(x) DenaliMemAlloc( x, __FILE__, __LINE__ )
  16. #define calloc(x,y) DenaliMemCalloc( x, y, __FILE__, __LINE__ )
  17. #define realloc(x,y) DenaliMemReAlloc( x, y, __FILE__, __LINE__ )
  18. #define free(x) DenaliMemFree( x, __FILE__, __LINE__ )
  19. #define DenaliMemoryInit() DenaliMemInit( __FILE__, __LINE__ )
  20. #define DenaliMemoryUnInit() DenaliMemUnInit( __FILE__, __LINE__ )
  21. #define DenaliDiagnostics() DenaliMemDiagnostics( __FILE__, __LINE__ )
  22. #define DenaliIsValid(x) DenaliMemIsValid(x)
  23. // Functions that are actually linked
  24. extern HRESULT DenaliMemInit(const char *szFile, int lineno);
  25. extern void DenaliMemUnInit(const char *szFile, int lineno);
  26. extern void DenaliMemDiagnostics(const char *szFile, int lineno);
  27. extern void DenaliLogCall(const char *szLog, const char *szFile, int lineno);
  28. extern void * DenaliMemAlloc(size_t cSize, const char *szFile, int lineno );
  29. extern void * DenaliMemCalloc(size_t cNum, size_t cbSize, const char *szFile, int lineno );
  30. extern void DenaliMemFree(void * p, const char *szFile, int lineno);
  31. extern void * DenaliMemReAlloc(void * p, size_t cSize, const char *szFile, int lineno);
  32. extern int DenaliMemIsValid(void * p);
  33. // Redefinition of global operators new and delete
  34. #ifdef __cplusplus
  35. // override for the default operator new
  36. inline void * __cdecl operator new(size_t cSize)
  37. {
  38. return DenaliMemAlloc(cSize, NULL, 0);
  39. }
  40. // override for the custom operator new with 3 args
  41. inline void * operator new(size_t cSize, const char *szFile, int lineno)
  42. {
  43. return DenaliMemAlloc(cSize, szFile, lineno);
  44. }
  45. // override for the default operator delete
  46. inline void __cdecl operator delete(void * p)
  47. {
  48. DenaliMemFree(p, NULL, 0);
  49. }
  50. // Macro to grab source file and line number information
  51. #define new new( __FILE__, __LINE__ )
  52. /*
  53. #define delete DenaliLogCall( "Calling delete operator", __FILE__, __LINE__ ), delete
  54. */
  55. #endif // __cplusplus
  56. #endif // MEMCHK_H