diff --git a/hipadaba.c b/hipadaba.c index 594e638c..9477eb67 100644 --- a/hipadaba.c +++ b/hipadaba.c @@ -158,12 +158,12 @@ static pHdbCallback DeleteForID(pHdbCallback root, int id){ return result; } /*-----------------------------------------------------------------------*/ -static pHdbCallback DeleteForInternalID(pHdbCallback root, int id){ +static pHdbCallback DeleteForInternalID(pHdbCallback root, void *id){ pHdbCallback current = root; pHdbCallback tmp = NULL; pHdbCallback result = NULL; - if(root == NULL){ + if(root == NULL || id == NULL){ return NULL; } @@ -729,7 +729,7 @@ char *GetHipadabaPath(pHdb node){ /*==================== Callback Functions ==================================*/ pHdbCallback MakeHipadabaCallback(hdbCallbackFunction func, void *userData, killUserData killFunc, - int id, int internalID){ + int id, void *internalID){ pHdbCallback pNew = NULL; assert(func != NULL); @@ -751,6 +751,7 @@ pHdbCallback MakeHipadabaCallback(hdbCallbackFunction func, void AppendHipadabaCallback(pHdb node, int type, pHdbCallback newCB){ pHdbCallback current = NULL; + assert(node); switch(type){ case HCBSET: if(node->writeCallbacks == NULL){ @@ -860,7 +861,7 @@ void RemoveHipadabaCallback(pHdb root, int id){ } } /*----------------------------------------------------------------------------*/ -void InternalRemoveHipadabaCallback(pHdb root, int internalID){ +void InternalRemoveHipadabaCallback(pHdb root, void *internalID){ pHdb current = NULL; root->writeCallbacks = DeleteForInternalID(root->writeCallbacks,internalID); diff --git a/hipadaba.h b/hipadaba.h index fdc90d56..6ff1b7f0 100644 --- a/hipadaba.h +++ b/hipadaba.h @@ -87,7 +87,7 @@ typedef struct __hdbcallback { killUserData killFunc; hdbCallbackFunction userCallback; int id; - int internalID; + void *internalID; struct __hdbcallback *next; struct __hdbcallback *previous; }hdbCallback, *pHdbCallback; @@ -250,14 +250,14 @@ int CountHdbChildren(pHdb node); * @param killFunc A function for freeing the userData. Can be NULL, then it will * not be invoked * @param id An ID associated with this callback - * @param internalID Another ID to be associated with this callback. ID's come in - * useful when callbacks have to be deleted in a later stage. - * @return A new suitabvly initialised callback structure or NULL when required elements + * @param internalID Another ID to be associated with this callback. Typically a + * reference to the owner object responsible for deleting the callback. + * @return A new suitabaly initialised callback structure or NULL when required elements * are missing or there is nor memory. */ pHdbCallback MakeHipadabaCallback(hdbCallbackFunction func, void *userData, killUserData killFunc, - int id, int internalID); + int id, void *internalID); /** * add a callback at the end of the callback chain * @param node The node to which to append the callback @@ -283,7 +283,7 @@ void RemoveHipadabaCallback(pHdb root, int id); * @param root The starting node from where to start removing callbacks * @param internalID The internal ID callbacks have to match in order to be removed. */ -void InternalRemoveHipadabaCallback(pHdb root, int internalID); +void InternalRemoveHipadabaCallback(pHdb root, void *internalID); /** * invoke a callback chain. * @param root The callback chain to invoke