static void reset_cache(struct exfat* ef, struct exfat_node* node) { char buffer[UTF8_BYTES(EXFAT_NAME_MAX) + 1]; while (node->child) { struct exfat_node* p = node->child; reset_cache(ef, p); tree_detach(p); free(p); } node->flags &= ~EXFAT_ATTRIB_CACHED; if (node->references != 0) { exfat_get_name(node, buffer, sizeof(buffer) - 1); exfat_warn("non-zero reference counter (%d) for '%s'", node->references, buffer); } if (node != ef->root && (node->flags & EXFAT_ATTRIB_DIRTY)) { exfat_get_name(node, buffer, sizeof(buffer) - 1); exfat_bug("node '%s' is dirty", buffer); } while (node->references) exfat_put_node(ef, node); }
static TREE_IT_CALLBK(release) { TREE_OBJ(struct tex_tr, p, tnd); BOOL res; res = tree_detach(&p->tnd, pa_now, pa_fwd); cp_free(p); return res; }
static LIST_IT_CALLBK(son_pass) { TREE_OBJ(struct tex_tr, son, tnd); BOOL res; P_CAST(gf/* grandfather */, struct tex_tr, pa_extra); if (gf == NULL) return LIST_RET_BREAK; res = tree_detach(&son->tnd, pa_now, pa_fwd); tree_attach(&son->tnd, &gf->tnd, pa_now, pa_fwd); return res; }
/* release resource callback function */ static TREE_IT_CALLBK(release) { TREE_OBJ(struct T, p, tnd); BOOL res; printf("free %d \n", p->i); res = tree_detach(&p->tnd, pa_now, pa_fwd); /* Or you can use: * res = list_detach_one(pa_now->now, pa_head, pa_now, pa_fwd); * This however, will not set father of each to NULL, but this * really doesn't matter because you are releasing the tree. */ free(p); return res; }
static void reset_cache(struct exfat* ef, struct exfat_node* node) { while (node->child) { struct exfat_node* p = node->child; reset_cache(ef, p); tree_detach(p); free(p); } node->flags &= ~EXFAT_ATTRIB_CACHED; if (node->references != 0) { char buffer[EXFAT_NAME_MAX + 1]; exfat_get_name(node, buffer, EXFAT_NAME_MAX); exfat_warn("non-zero reference counter (%d) for `%s'", node->references, buffer); } while (node->references) exfat_put_node(ef, node); }
static TREE_IT_CALLBK(prune) { TREE_OBJ(struct tex_tr, p, tnd); P_CAST(n_pruned, uint32_t, pa_extra); BOOL res; if (p->tnd.sons.now == NULL /* is leaf */ && NULL != p->tnd.father /* can be pruned */) { /* prune ... */ if (p->n_fan == 0 /* grouped nodes */ || p->token_id == T_NIL /* nil nodes */) { res = tree_detach(&p->tnd, pa_now, pa_fwd); tex_tr_release(p); ++(*n_pruned); return res; } } LIST_GO_OVER; }
/* pluck an 8 and plug it under branch 5 */ static TREE_IT_CALLBK(pluck_and_plug) { TREE_OBJ(struct T, p, tnd); P_CAST(pluck, struct T *, pa_extra); if (p->i == 8) { if (!(*pluck)) { *pluck = p; return tree_detach(&p->tnd, pa_now, pa_fwd); } } if (p->i == 5) { if (*pluck) { tree_attach(&(*pluck)->tnd, &p->tnd, pa_now, pa_fwd); return LIST_RET_BREAK; } } LIST_GO_OVER; }