static void free_leaf( extbmp_t *ebmp, tnode_t *leaf ) { dbmsg("free_leaf( ebmp, leaf=0x%08x", leaf); ebmp->leaf_count -= 1; if (leaf == (tnode_t*)ebmp->mru_cache.leaf) { ebmp->mru_cache.leaf = NULL; ebmp->mru_cache.first_addr_for_leaf = 0; } { leaf_t *l; l = &leaf->leaf; if (l->next_for_gno != NULL) l->next_for_gno->prev_for_gno = l->prev_for_gno; if (l->prev_for_gno != NULL) l->prev_for_gno->next_for_gno = l->next_for_gno; if (ebmp->gno_to_leaf[ l->gno ] == l) { ebmp->gno_to_leaf[ l->gno ] = l->next_for_gno; } } free_tnode( ebmp, leaf, tag_leaf, (sizeof( leaf_t ) + ebmp->leaf_words*sizeof(word))); }
static void free_inode( extbmp_t *ebmp, tnode_t *inode ) { dbmsg("free_inode( ebmp, inode=0x%08x", inode); free_tnode( ebmp, inode, tag_inode, (sizeof( inode_t ) + ebmp->entries_per_inode*sizeof( tnode_t* ))); }
/* free_tnode() - frees a node in the B-tree, * its associated record, and all its children from memory */ void free_tnode(p_tnode pnode) { unsigned int n; for (n = 0; n < 2*T; n++) { if (pnode->children[n] != NULL) free_tnode(pnode->children[n]); } for (n = 0; n < pnode->nkeys; n++) { if (pnode->values[n]) free_record(pnode->values[n]); } free(pnode); }
void cleanup(void) { if (ptreeroot) { free_tnode(ptreeroot); ptreeroot = NULL; } }