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

This commit is contained in:
Michael Graff
2000-05-10 17:45:45 +00:00
parent bc892aec31
commit 2968701c3a
+12 -4
View File
@@ -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 */