예제 #1
0
파일: dbtree.c 프로젝트: TheWorm/dbtree
void dbtree_destroy(dbtree *tree) {
    if (tree->next)
	dbtree_destroy(tree->next);
    if (tree->child)
	dbtree_destroy(tree->child);
    while (tree) {
	dbtree *next = tree->next;
	if (tree->size > 0 && tree->value != NULL)
	    free(tree->value);
	free(tree);
	tree = next;
    }
}
예제 #2
0
파일: btree.c 프로젝트: daos-stack/daos
static int
ik_btr_close_destroy(bool destroy)
{
	int rc;

	if (daos_handle_is_inval(ik_toh)) {
		D_ERROR("Invalid tree open handle\n");
		return -1;
	}

	if (destroy) {
		D_PRINT("Destroy btree\n");
		rc = dbtree_destroy(ik_toh);
	} else {
		D_PRINT("Close btree\n");
		rc = dbtree_close(ik_toh);
	}

	ik_toh = DAOS_HDL_INVAL;
	if (rc != 0) {
		D_ERROR("Tree %s failed: %d\n",
			destroy ? "destroy" : "close", rc);
		return -1;
	}
	return rc;
}