void ai_btree_delete_ibtr(bt * ibtr) { if (! ibtr) { cf_crash(AS_SINDEX, "IBTR is null"); } destroy_index(ibtr, ibtr->root); }
static void destroy_index(bt *ibtr, bt_n *n) { if (! n->leaf) { for (int i = 0; i <= n->n; i++) { destroy_index(ibtr, NODES(ibtr, n)[i]); } } for (int i = 0; i < n->n; i++) { void *be = KEYS(ibtr, n, i); ai_nbtr *anbtr = (ai_nbtr *) parseStream(be, ibtr); if (anbtr) { if (anbtr->is_btree) { bt_destroy(anbtr->u.nbtr); } else { ai_arr_destroy(anbtr->u.arr); } cf_free(anbtr); } } }
/* method_free_index * * called by ruby when it's trying to free the instantiated * DupleIndex class. In this method, we start the deallocation * of memory by iterating over each hash member and calling * free successively. */ static void method_free_index(void *duples) { destroy_index( duples ); }