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.

26 lines
1.4 KiB

  1. #pragma once
  2. #if DBG
  3. #define ASSERT(x) if (!(x)) { EnsureDebuggerPresent(); DebugBreak(); }
  4. #else
  5. #define ASSERT(x)
  6. #endif
  7. // The only error we don't break on.
  8. #define PREDICATE _hr == E_ABORT
  9. #define HEAPCHK if (!DoHeapValidate()) ASSERT(FALSE);
  10. #define SAFEDELETE(p) if ((p) != NULL) { delete (p); (p) = NULL; };
  11. #define SAFEDELETEARRAY(p) if ((p) != NULL) { delete[] (p); (p) = NULL; };
  12. #define SAFERELEASE(p) if ((p) != NULL) { (p)->Release(); (p) = NULL; };
  13. #define MAKE_ERROR_MACROS_STATIC(_x) HRESULT &_hr = _x;
  14. #define IF_FAILED_EXIT(_x) do {_hr = (_x); if (FAILED(_hr)) { ASSERT(PREDICATE); goto exit; } } while (0)
  15. #define IF_NULL_EXIT(_x, _y) do {if ((_x) == NULL) {_hr = _y; ASSERT(PREDICATE); goto exit; } } while (0)
  16. #define IF_FALSE_EXIT(_x, _y) do { if ((_x) == FALSE) {_hr = _y; ASSERT(PREDICATE); goto exit; } } while (0)
  17. #define IF_ALLOC_FAILED_EXIT(_x) do { if ((_x) == NULL) {_hr = E_OUTOFMEMORY; ASSERT(PREDICATE); goto exit; } } while (0)
  18. #define IF_WIN32_FAILED_EXIT(_x) do { _hr = (HRESULT_FROM_WIN32(_x)); if (FAILED(_hr)) { ASSERT(PREDICATE); goto exit; } } while (0)
  19. #define IF_WIN32_FALSE_EXIT(_x) do { if (!_x) { DWORD dw=GetLastError(); _hr = (dw? HRESULT_FROM_WIN32(dw) : E_FAIL ); } else {_hr = S_OK;} if (FAILED(_hr)) {ASSERT(PREDICATE); goto exit;} } while (0)
  20. #define IF_TRUE_EXIT(_x, _y) do { if (_x) { _hr = _y; goto exit;} } while (0)