static void tear_down(struct cstat **cstat) { sdirs_free((struct sdirs **)&(*cstat)->sdirs); cstat_free(cstat); alloc_check(); clean(); }
void cstat_list_free(struct cstat **clist) { struct cstat *c; struct cstat *next; struct cstat *prev=NULL; if(*clist) prev=(*clist)->prev; for(c=*clist; c; c=next) { next=c->next; cstat_free(&c); } // Do it in both directions. for(c=prev; c; c=prev) { prev=c->prev; cstat_free(&c); } *clist=NULL; }
static void cstat_remove(struct cstat **clist, struct cstat **cstat) { struct cstat *c; if(!cstat || !*cstat) return; if(*clist==*cstat) { *clist=(*cstat)->next; cstat_free(cstat); *cstat=*clist; return; } for(c=*clist; c; c=c->next) { if(c->next!=*cstat) continue; c->next=(*cstat)->next; cstat_free(cstat); *cstat=*clist; return; } }
static void cstat_free_w(struct cstat **cstat) { sdirs_free((struct sdirs **)&(*cstat)->sdirs); cstat_free(cstat); }