void listObserverDetach(LIST_OBSERVER_T *observer, LIST_T *list) { if (observer->list) listRemoveEntry(observer->list, (LIST_ENTRY_T *)observer); observer->list = NULL; }
/* listPop() * * Remove the element from the forw pointer of the * list. */ LIST_ENTRY_T * listPop(LIST_T *list) { LIST_ENTRY_T *ent; if (LIST_IS_EMPTY(list)) return NULL; ent = list->forw; listRemoveEntry(list, ent); return ent; }
void listDestroy(LIST_T *list, void (*destroy)(LIST_ENTRY_T *)) { LIST_ENTRY_T *entry; while (! LIST_IS_EMPTY(list)) { entry = list->forw; listRemoveEntry(list, entry); if (destroy) (*destroy)(entry); else free(entry); } free(list->name); free(list); }
void listDestroy(LIST_T *list, void (*destroy)(LIST_ENTRY_T *)) { LIST_ENTRY_T *entry; while (! LIST_IS_EMPTY(list)) { entry = list->forw; listRemoveEntry(list, entry); if (destroy) (*destroy)(entry); else free(entry); } if (list->allowObservers) { listDestroy(list->observers, (LIST_ENTRY_DESTROY_FUNC_T)&listObserverDestroy); } free(list->name); free(list); }