Microsoft® DirectShow™ provides some macros to make pointer usage more robust. These include a simple CheckPointer macro (which tests if a given pointer is NULL). These also include a number of ValidateXxxPtr macros, which ensure a given pointer actually refers to the correct kind of memory, although possibly with a significant performance hit for each test.
Name | Description |
CheckPointer | Checks whether or not a given pointer is NULL. |
ValidateReadPtr | Validates a read pointer. |
ValidateReadWritePtr | Validates a read/write pointer. |
ValidateStringPtr | Validates a string pointer. |
ValidateStringPtrA | Validates an ANSI string pointer. |
ValidateStringPtrW | Validates a wide (Unicode) string pointer. |
ValidateWritePtr | Validates a write pointer. |
Determines if a given pointer is NULL. If the pointer is NULL, CheckPointer returns a user-defined value.
CheckPointer(
p,
ret
);
The following examples illustrate how to call this macro.
HRESULT OneFunction(VOID *pSomeParameter) { CheckPointer(pSomeParameter, E_INVALIDARG) } BOOL AnotherFunction(VOID *pSomeParameter) { CheckPointer(pSomeParameter, FALSE) }
Checks a read pointer. If the pointer is not valid, this macro calls DbgBreak.
ValidateReadPtr(
const void * p,
UINT cb
);
This macro is ignored unless DEBUG or VFWROBUST is defined when the Microsoft DirectShow headers are included.
Checks a read/write pointer. If the pointer is not valid, this macro calls DbgBreak.
ValidateReadWritePtr(
const void * p,
UINT cb
);
This macro is ignored unless DEBUG or VFWROBUST is defined when the Microsoft DirectShow headers are included.
Checks a string pointer and calls DbgBreak if the pointer is not valid.
ValidateStringPtr(
LPCTSTR p
);
This macro is ignored unless DEBUG or VFWROBUST is defined when the Microsoft DirectShow headers are included.
Checks an ANSI string pointer and calls DbgBreak if the pointer is not valid.
ValidateStringPtrA(
LPCSTR p
);
This macro is ignored unless DEBUG or VFWROBUST is defined when the Microsoft DirectShow headers are included.
Checks a wide (Unicode) string pointer and calls DbgBreak if the pointer is not valid.
ValidateStringPtrW(
LPCWSTR p
);
This macro is ignored unless DEBUG or VFWROBUST is defined when the Microsoft DirectShow headers are included.
Checks a write pointer and calls DbgBreak if the pointer is not valid.
ValidateWritePtr(
const void * p,
UINT cb
);
This macro is ignored unless DEBUG or VFWROBUST is defined when the Microsoft DirectShow headers are included.
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.