]> git.ipfire.org Git - thirdparty/git.git/blame - reftable/tree.h
commit-reach(repo_get_merge_bases_many): pass on "missing commits" errors
[thirdparty/git.git] / reftable / tree.h
CommitLineData
35425d10
HWN
1/*
2Copyright 2020 Google LLC
3
4Use of this source code is governed by a BSD-style
5license that can be found in the LICENSE file or at
6https://developers.google.com/open-source/licenses/bsd
7*/
8
9#ifndef TREE_H
10#define TREE_H
11
12/* tree_node is a generic binary search tree. */
13struct tree_node {
14 void *key;
15 struct tree_node *left, *right;
16};
17
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.
20 */
21struct tree_node *tree_search(void *key, struct tree_node **rootp,
22 int (*compare)(const void *, const void *),
23 int insert);
24
25/* performs an infix walk of the tree. */
26void infix_walk(struct tree_node *t, void (*action)(void *arg, void *key),
27 void *arg);
28
29/*
30 * deallocates the tree nodes recursively. Keys should be deallocated separately
31 * by walking over the tree. */
32void tree_free(struct tree_node *t);
33
34#endif