2 Copyright 2020 Google LLC
4 Use of this source code is governed by a BSD-style
5 license that can be found in the LICENSE file or at
6 https://developers.google.com/open-source/licenses/bsd
12 /* tree_node is a generic binary search tree. */
15 struct tree_node
*left
, *right
;
18 /* looks for `key` in `rootp` using `compare` as comparison function. If insert
19 * is set, insert the key if it's not found. Else, return NULL.
21 struct tree_node
*tree_search(void *key
, struct tree_node
**rootp
,
22 int (*compare
)(const void *, const void *),
25 /* performs an infix walk of the tree. */
26 void infix_walk(struct tree_node
*t
, void (*action
)(void *arg
, void *key
),
30 * deallocates the tree nodes recursively. Keys should be deallocated separately
31 * by walking over the tree. */
32 void tree_free(struct tree_node
*t
);