git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
0061d14e306c0a28c77252590173c1c459dac04e blob 1246 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
 
/*
Copyright 2020 Google LLC

Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file or at
https://developers.google.com/open-source/licenses/bsd
*/

#include "tree.h"

#include "basics.h"
#include "system.h"

struct tree_node *tree_search(void *key, struct tree_node **rootp,
			      int (*compare)(const void *, const void *),
			      int insert)
{
	int res;
	if (*rootp == NULL) {
		if (!insert) {
			return NULL;
		} else {
			struct tree_node *n =
				reftable_calloc(sizeof(struct tree_node));
			n->key = key;
			*rootp = n;
			return *rootp;
		}
	}

	res = compare(key, (*rootp)->key);
	if (res < 0)
		return tree_search(key, &(*rootp)->left, compare, insert);
	else if (res > 0)
		return tree_search(key, &(*rootp)->right, compare, insert);
	return *rootp;
}

void infix_walk(struct tree_node *t, void (*action)(void *arg, void *key),
		void *arg)
{
	if (t->left != NULL) {
		infix_walk(t->left, action, arg);
	}
	action(arg, t->key);
	if (t->right != NULL) {
		infix_walk(t->right, action, arg);
	}
}

void tree_free(struct tree_node *t)
{
	if (t == NULL) {
		return;
	}
	if (t->left != NULL) {
		tree_free(t->left);
	}
	if (t->right != NULL) {
		tree_free(t->right);
	}
	reftable_free(t);
}
debug log:

solving 0061d14e306c ...
found 0061d14e306c in https://public-inbox.org/git/b6eed7283aac77d65d9127408b0571ab13e46650.1615580397.git.gitgitgadget@gmail.com/ ||
	https://public-inbox.org/git/ceddefadd48c772ea124078d59a76d634d1db1be.1618255553.git.gitgitgadget@gmail.com/

applying [1/2] https://public-inbox.org/git/b6eed7283aac77d65d9127408b0571ab13e46650.1615580397.git.gitgitgadget@gmail.com/
diff --git a/reftable/tree.c b/reftable/tree.c
new file mode 100644
index 000000000000..0061d14e306c

Checking patch reftable/tree.c...
Applied patch reftable/tree.c cleanly.

skipping https://public-inbox.org/git/ceddefadd48c772ea124078d59a76d634d1db1be.1618255553.git.gitgitgadget@gmail.com/ for 0061d14e306c
index at:
100644 0061d14e306c0a28c77252590173c1c459dac04e	reftable/tree.c

Code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).