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

//+-------------------------------------------------------------------------
//
// Microsoft Windows
//
// Copyright (C) Microsoft Corporation, 1998 - 2002
//
// File: common.h
//
//--------------------------------------------------------------------------
#ifndef __common_h
#define __common_h
//
// Avoid bringing in C runtime code for NO reason
//
#include "wianew.h"
#include "debug.h"
#include "dbmem.h"
#include "cunknown.h"
#include "strings.h"
#ifndef ARRAYSIZE
#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
#endif
#ifndef SIZEOF
#define SIZEOF(a) sizeof(a)
#endif
/*-----------------------------------------------------------------------------
/ Flags to control the trace output from parts of the common library
/----------------------------------------------------------------------------*/
#define TRACE_COMMON_STR 0x80000000
#define TRACE_COMMON_ASSERT 0x40000000
#define TRACE_COMMON_MEMORY 0x20000000
/*-----------------------------------------------------------------------------
/ Exit macros for macro
/ - these assume that a label "exit_gracefully:" prefixes the prolog
/ to your function
/----------------------------------------------------------------------------*/
#define ExitGracefully(hr, result, text) \
{ TraceMsg(text); hr = result; goto exit_gracefully; }
#define FailGracefully(hr, text) \
{ if ( FAILED(hr) ) { TraceMsg(text); goto exit_gracefully; } }
/*-----------------------------------------------------------------------------
/ Object / memory release macros
/----------------------------------------------------------------------------*/
#define DoRelease(pInterface) \
{ if ( pInterface ) { pInterface->Release(); pInterface = NULL; } }
#define DoILFree(pidl) \
{ if (pidl) {ILFree((LPITEMIDLIST)pidl); pidl = NULL;} }
#define DoLocalFree(p) \
{ if (p) {LocalFree((HLOCAL)p); p = NULL;} }
#define DoCloseHandle(h) \
{ if (h) {CloseHandle((HANDLE)h); h = NULL;} }
#define DoDelete(ptr) \
{ if (ptr) {delete ptr; ptr=NULL;}}
/*-----------------------------------------------------------------------------
/ Other helpful macros
/----------------------------------------------------------------------------*/
#define ByteOffset(base, offset) \
(((LPBYTE)base)+offset)
#endif