From 8b73362a4a88aaa3642db398d17e65eab871d9ed Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Tue, 29 Jan 2008 08:35:26 +0000 Subject: - improved debug support a bit (assertions) - restructured code, moved some part out of syslogd.c to action.c, where they belong (still some more to do in that regard ;)) --- obj-types.h | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'obj-types.h') diff --git a/obj-types.h b/obj-types.h index 1e607d0c..01842a83 100644 --- a/obj-types.h +++ b/obj-types.h @@ -30,6 +30,11 @@ #include "stringbuf.h" +/* base object data, present in all objects */ +typedef struct objData_s { + uchar *pName; +} objData_t; + /* property types */ typedef enum { /* do NOT start at 0 to detect uninitialized types after calloc() */ PROPTYPE_PSZ = 1, @@ -85,9 +90,11 @@ 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 } obj_t; @@ -98,25 +105,21 @@ typedef struct obj { /* the dummy struct that each derived class can be casted t #ifndef NDEBUG /* this means if debug... */ # define BEGINobjInstance \ objInfo_t *pObjInfo; \ + objData_t objData; \ unsigned int iObjCooCKiE; /* prevent name conflict, thus the strange name */ # define ISOBJ_assert(pObj) \ do { \ - if(pObj == NULL) dbgPrintAllDebugInfo(); \ - assert((pObj) != NULL); \ - if(((obj_t*)(pObj))->iObjCooCKiE != (unsigned) 0xBADEFEE) dbgPrintAllDebugInfo(); \ - assert((unsigned) ((obj_t*)(pObj))->iObjCooCKiE == (unsigned) 0xBADEFEE); \ + ASSERT((pObj) != NULL); \ + ASSERT((unsigned) ((obj_t*)(pObj))->iObjCooCKiE == (unsigned) 0xBADEFEE); \ } while(0); # define ISOBJ_TYPE_assert(pObj, objType) \ do { \ - if(pObj == NULL) dbgPrintAllDebugInfo(); \ - assert(pObj != NULL); \ - if(((obj_t*)(pObj))->iObjCooCKiE != (unsigned) 0xBADEFEE) dbgPrintAllDebugInfo(); \ - assert((unsigned) pObj->iObjCooCKiE == (unsigned) 0xBADEFEE); \ - if(objGetObjID(pObj) != OBJ##objType) dbgPrintAllDebugInfo(); \ - assert(objGetObjID(pObj) == OBJ##objType); \ + ASSERT(pObj != NULL); \ + ASSERT((unsigned) 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; +# define BEGINobjInstance objInfo_t *pObjInfo; objData_t objData; # define ISOBJ_TYPE_assert(pObj, objType) # define ISOBJ_assert(pObj) #endif -- cgit