tags:

views:

96

answers:

4
#define ValidateReadPtr(p,cb) 0

I can't think of a use case for this kind of macro,what about you?

+3  A: 

It was probably used for something else, and then was redefined as 0.

That's the beauty of macros, you can use them in your code, and then, one simple redefinition is good enough to change all occurrences of that macro in the code.

What's probably happening now is the programmer wants that validation (ValidateReadPtr) always return FALSE (0 in C/C++).

Pablo Santa Cruz
But that macro doesn't do any actual validation against Pointer at all.
Alan
No, right now it doesn't. But probably in previous versions on the code it did...
Pablo Santa Cruz
A: 
if (!ValidateReadPtr(p,cb))
   printf("Your ReadPtr is valid\n");

;)

sizzzzlerz
+3  A: 

See here: http://msdn.microsoft.com/en-us/library/dd407304(VS.85).aspx

Vinzenz
+2  A: 

I can only find the ValidateReadPtr() macro in the wxdebug.h header for the Windows Mobile SDK (even though MSDN indicates it's part of the DirectShow APIs).

In wxdebug.h it's defined as:

#define ValidateReadPtr(p,cb) \
    {if(IsBadReadPtr((PVOID)p,cb) == TRUE) \
        DbgBreak("Invalid read pointer");}

I suspect that in your project it's defined as 0 for one or both of the following reasons:

  • to make the code that uses it compile even when the wxdebug.h header isn't available (ie., not using the Windows Mobile SDK)
  • IsBadReadPtr() is now considered a dangerous API that shouldn't be used. The docs for IsBadreadPtr() say, "Important This function is obsolete and should not be used. Despite its name, it does not guarantee that the pointer is valid or that the memory pointed to is safe to use. For more information, see Remarks...". And Raymond Chen wrote an article about the problems with IsBadReadPtr(): IsBadXxxPtr should really be called CrashProgramRandomly
Michael Burr