/* NOTE: only needed for memory based index */ void RTreeDestroyNode(struct RTree_Node *n, int nodes) { int i; if (n->level > 0) { /* it is not leaf -> destroy childs */ for (i = 0; i < nodes; i++) { if (n->branch[i].child.ptr) { RTreeDestroyNode(n->branch[i].child.ptr, nodes); } } } /* Free this node */ RTreeFreeNode(n); return; }
static void RTreeDestroyNode (node_t node) { int i; if (node->level == 0) /* leaf level*/ { for (i = 0; i < MAXCARD; i++) if (node->branch[i].child) continue;/* allow user free data*/ else break; } else { for (i = 0; i < MAXCARD; i++) if (node->branch[i].child) RTreeDestroyNode (node->branch[i].child); else break; } free (node); }
void RTreeDestroy (rtree_t t) { if (t) RTreeDestroyNode (t); }