Commit 2968701c authored by Michael Graff's avatar Michael Graff
Browse files

require that magic numbers be the first item in the structure.

parent bc892aec
......@@ -18,10 +18,18 @@
#ifndef ISC_MAGIC_H
#define ISC_MAGIC_H 1
#define ISC_MAGIC_VALID(a,b) (((a) != NULL) && ((a)->magic == (b)))
typedef struct {
unsigned int magic;
} isc__magic_t;
#define ISC_MAGIC(a, b, c, d) ((unsigned int)(a) << 24 \
| (unsigned int)(b) << 16 \
| (unsigned int)(c) << 8 | (d))
/*
* To use this macro the magic number MUST be the first thing in the
* structure, and MUST be of type "unsigned int"
*/
#define ISC_MAGIC_VALID(a,b) (((a) != NULL) \
&& (((isc__magic_t *)(a))->magic == (b)))
#define ISC_MAGIC(a, b, c, d) ((a) << 24 | (b) << 16 | (c) << 8 | (d))
#endif /* ISC_MAGIC_H */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment