BRL-CAD
|
Global registry of recognized magic numbers. More...
Files | |
file | magic.h |
Global registry of recognized magic numbers. | |
Functions | |
NORETURN void | bu_badmagic (const uint32_t *ptr, uint32_t magic, const char *str, const char *file, int line) |
const char * | bu_identify_magic (uint32_t magic) |
Routines involved with handling "magic numbers" used to identify various in-memory data structures. | |
Global registry of recognized magic numbers.
Magic numbers provide a means to perform run-time sanity checks for memory corruption and uninitialized data.
The one ugly thing about this implementation is that every BRL-CAD structure needs to have its magic number registered here and in the header.
This file is part of LIBBU even though it provides magic numbers for structures in other libraries.
The defines should be considered PRIVATE (even though they are not) and should NEVER be referenced by value.
#define NMG_EDGEUSE2_MAGIC 0x91919191 |
#define RT_DIR_MAGIC 0x05551212 |
Routines involved with handling "magic numbers" used to identify various in-memory data structures.
Macros to check and validate a structure pointer, given that the first entry in the structure is a magic number. ((void)(1?0:((_ptr), void(), 0)))
|
extern |
This function is called when there is something wrong with a pointer. It's primarily a support routine for BU_CKMAG macro, but may be used elsewhere. This function never returns.
Routines involved with handling "magic numbers" used to identify various in-memory data structures.
Given a number which has been found in the magic number field of a structure (which is typically the first entry), determine what kind of structure this magic number pertains to. This is called by the macro BU_CK_MAGIC() to provide a "hint" as to what sort of pointer error might have been made.