/* Function: free_ModuleFunctionList(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ModuleFunctionList *] * * Return [UNKN ] Undocumented return value [ModuleFunctionList *] * */ ModuleFunctionList * free_ModuleFunctionList(ModuleFunctionList * obj) { int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ModuleFunctionList obj. Should be trappable"); return NULL; } if( obj->dynamite_hard_link > 1) { obj->dynamite_hard_link--; return NULL; } if( obj->mf != NULL) { for(i=0;i<obj->len;i++) { if( obj->mf[i] != NULL) free_ModuleFunction(obj->mf[i]); } ckfree(obj->mf); } ckfree(obj); return NULL; }
/* Function: flush_ModuleFunctionList(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [ModuleFunctionList *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_ModuleFunctionList(ModuleFunctionList * obj) { int i; for(i=0;i<obj->len;i++) { /*for i over list length*/ if( obj->mf[i] != NULL) { free_ModuleFunction(obj->mf[i]); obj->mf[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; }
/* Function: free_ModuleFunctionList(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ModuleFunctionList *] * * Return [UNKN ] Undocumented return value [ModuleFunctionList *] * */ ModuleFunctionList * free_ModuleFunctionList(ModuleFunctionList * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ModuleFunctionList obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->mf != NULL) { for(i=0;i<obj->len;i++) { if( obj->mf[i] != NULL) free_ModuleFunction(obj->mf[i]); } ckfree(obj->mf); } ckfree(obj); return NULL; }