summaryrefslogtreecommitdiffstats
path: root/obj-types.h
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-01-29 10:23:10 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2008-01-29 10:23:10 +0000
commit19cad8b12fa34e05f903c1d55c77453be1bab431 (patch)
treea7f3a8c4ec25c1670530933aeea498330d3ab70a /obj-types.h
parent33a8ec9855b7e7674ab2b1a6e4814b08652296de (diff)
downloadrsyslog-19cad8b12fa34e05f903c1d55c77453be1bab431.tar.gz
rsyslog-19cad8b12fa34e05f903c1d55c77453be1bab431.tar.xz
rsyslog-19cad8b12fa34e05f903c1d55c77453be1bab431.zip
implemented naming for all objects (mostly as a debug aid, but you never
know what else it will be good for)
Diffstat (limited to 'obj-types.h')
-rw-r--r--obj-types.h19
1 files changed, 7 insertions, 12 deletions
diff --git a/obj-types.h b/obj-types.h
index 01842a83..bd0da73e 100644
--- a/obj-types.h
+++ b/obj-types.h
@@ -29,11 +29,7 @@
#define OBJ_TYPES_H_INCLUDED
#include "stringbuf.h"
-
-/* base object data, present in all objects */
-typedef struct objData_s {
- uchar *pName;
-} objData_t;
+#include "syslogd-types.h"
/* property types */
typedef enum { /* do NOT start at 0 to detect uninitialized types after calloc() */
@@ -90,23 +86,22 @@ typedef struct objInfo_s {
rsRetVal (*objMethods[OBJ_NUM_METHODS])();
} objInfo_t;
-/* TODO: move obj_t at front of struct */
+
typedef struct obj { /* the dummy struct that each derived class can be casted to */
objInfo_t *pObjInfo;
#ifndef NDEBUG /* this means if debug... */
- objData_t objData;
unsigned int iObjCooCKiE; /* must always be 0xBADEFEE for a valid object */
#endif
+ uchar *pszName; /* the name of *this* specific object instance */
} obj_t;
+
/* macros which must be gloablly-visible (because they are used during definition of
* other objects.
*/
#ifndef NDEBUG /* this means if debug... */
# define BEGINobjInstance \
- objInfo_t *pObjInfo; \
- objData_t objData; \
- unsigned int iObjCooCKiE; /* prevent name conflict, thus the strange name */
+ obj_t objData;
# define ISOBJ_assert(pObj) \
do { \
ASSERT((pObj) != NULL); \
@@ -115,11 +110,11 @@ typedef struct obj { /* the dummy struct that each derived class can be casted t
# define ISOBJ_TYPE_assert(pObj, objType) \
do { \
ASSERT(pObj != NULL); \
- ASSERT((unsigned) pObj->iObjCooCKiE == (unsigned) 0xBADEFEE); \
+ ASSERT((unsigned) ((obj_t*) (pObj))->iObjCooCKiE == (unsigned) 0xBADEFEE); \
ASSERT(objGetObjID(pObj) == OBJ##objType); \
} while(0);
#else /* non-debug mode, no checks but much faster */
-# define BEGINobjInstance objInfo_t *pObjInfo; objData_t objData;
+# define BEGINobjInstance objInfo_t *objData.pObjInfo; objData_t objData;
# define ISOBJ_TYPE_assert(pObj, objType)
# define ISOBJ_assert(pObj)
#endif