Next: , Previous: Binary tree structure, Up: Binary trees


14.2 Allocating and freeing binary trees

— Function: Bstree * bst_create (Bst_compare_f compare)

Uses ‘mem_alloc’ to allocate a ‘Bstree’ and initialises it to an empty bstree. Returns a reference to the allocated bstree, or a null pointer if there was insufficient memory.

— Function: void bst_destroy (Bstree *bst)

Finalises the internal data structures of bst, and then frees bst itself. bst must have been allocated by ‘bst_create’.