All pastes #413798 Raw Edit

Someone

public text v1 · immutable
#413798 ·published 2007-03-28 18:05 UTC
rendered paste body
 * @def BU_CKMAG(ptr,magic,string)
 *
 *  Macros to check and validate a structure pointer, given that
 *  the first entry in the structure is a magic number.
 */
#ifdef NO_BOMBING_MACROS
#  define BU_CKMAG(_ptr, _magic, _str)
#  define BU_CKMAG_TCL(_interp, _ptr, _magic, _str)
#else
#  define BU_CKMAG(_ptr, _magic, _str)  \
        if( !(ptr)  || ((~_ptr) & (_ptr)) || \
        ( ((size_t)(_ptr)) & (sizeof(long)-1) ) || \
            *((unsigned long *)(_ptr)) != (unsigned long)(_magic) )  { \
                bu_badmagic( (long *)(_ptr), (unsigned long)_magic, _str, __FILE
        } \
        return;
#  define BU_CKMAG_TCL(_interp, _ptr, _magic, _str)     \
        if( !(_ptr) || ( ((size_t)(_ptr)) & (sizeof(long)-1) ) || \
             *((long *)(_ptr)) != (_magic) )  { \
                bu_badmagic_tcl( (_interp), (long *)(_ptr), (unsigned long)_magi
                return TCL_ERROR; \
        } \
        return;