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. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 2002
  6. //
  7. // File: common.h
  8. //
  9. //--------------------------------------------------------------------------
  10. #ifndef __common_h
  11. #define __common_h
  12. //
  13. // Avoid bringing in C runtime code for NO reason
  14. //
  15. #include "wianew.h"
  16. #include "debug.h"
  17. #include "dbmem.h"
  18. #include "cunknown.h"
  19. #include "strings.h"
  20. #ifndef ARRAYSIZE
  21. #define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
  22. #endif
  23. #ifndef SIZEOF
  24. #define SIZEOF(a) sizeof(a)
  25. #endif
  26. /*-----------------------------------------------------------------------------
  27. / Flags to control the trace output from parts of the common library
  28. /----------------------------------------------------------------------------*/
  29. #define TRACE_COMMON_STR 0x80000000
  30. #define TRACE_COMMON_ASSERT 0x40000000
  31. #define TRACE_COMMON_MEMORY 0x20000000
  32. /*-----------------------------------------------------------------------------
  33. / Exit macros for macro
  34. / - these assume that a label "exit_gracefully:" prefixes the prolog
  35. / to your function
  36. /----------------------------------------------------------------------------*/
  37. #define ExitGracefully(hr, result, text) \
  38. { TraceMsg(text); hr = result; goto exit_gracefully; }
  39. #define FailGracefully(hr, text) \
  40. { if ( FAILED(hr) ) { TraceMsg(text); goto exit_gracefully; } }
  41. /*-----------------------------------------------------------------------------
  42. / Object / memory release macros
  43. /----------------------------------------------------------------------------*/
  44. #define DoRelease(pInterface) \
  45. { if ( pInterface ) { pInterface->Release(); pInterface = NULL; } }
  46. #define DoILFree(pidl) \
  47. { if (pidl) {ILFree((LPITEMIDLIST)pidl); pidl = NULL;} }
  48. #define DoLocalFree(p) \
  49. { if (p) {LocalFree((HLOCAL)p); p = NULL;} }
  50. #define DoCloseHandle(h) \
  51. { if (h) {CloseHandle((HANDLE)h); h = NULL;} }
  52. #define DoDelete(ptr) \
  53. { if (ptr) {delete ptr; ptr=NULL;}}
  54. /*-----------------------------------------------------------------------------
  55. / Other helpful macros
  56. /----------------------------------------------------------------------------*/
  57. #define ByteOffset(base, offset) \
  58. (((LPBYTE)base)+offset)
  59. #endif