git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
blob 0061d14e306c0a28c77252590173c1c459dac04e 1246 bytes (raw)
name: reftable/tree.c 	 # note: path name is non-authoritative(*)

 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 0061d14e30 ...
found 0061d14e30 in https://public-inbox.org/git/17fb8d050dae2efd84f090268095da4d04b15c88.1600283416.git.gitgitgadget@gmail.com/ ||
	https://public-inbox.org/git/e30a7e02815121eeba34d7f27b352f675a7d9f60.1601568664.git.gitgitgadget@gmail.com/ ||
	https://public-inbox.org/git/24afac9c91a2eaf1529433a136d0f43aeae71550.1606419752.git.gitgitgadget@gmail.com/ ||
	https://public-inbox.org/git/6968dbc3828f22369cc92bf56e3a7855769415fa.1607522429.git.gitgitgadget@gmail.com/ ||
	https://public-inbox.org/git/b6eed7283aac77d65d9127408b0571ab13e46650.1615580397.git.gitgitgadget@gmail.com/ ||
	https://public-inbox.org/git/ceddefadd48c772ea124078d59a76d634d1db1be.1618255553.git.gitgitgadget@gmail.com/ ||
	https://public-inbox.org/git/86646c834c2d4046aa8734e5330beb827aeb8539.1592335243.git.gitgitgadget@gmail.com/ ||
	https://public-inbox.org/git/3c84f43cfa07708759b386f63dc4893ac45d0850.1592862921.git.gitgitgadget@gmail.com/ ||
	https://public-inbox.org/git/169f6c7f543f1d3e5c91a0b38961c765d6900107.1593457018.git.gitgitgadget@gmail.com/ ||
	https://public-inbox.org/git/12d98125c2bacdaab797cbaca47bdbfe000c293f.1596209238.git.gitgitgadget@gmail.com/ ||
	https://public-inbox.org/git/0bc28ac610fb6f5965e39f9e0d4caf88ca9ead06.1591380199.git.gitgitgadget@gmail.com/ ||
	https://public-inbox.org/git/718b646a54e241c0d201fa8ea24fe8838f51ccd7.1590695210.git.gitgitgadget@gmail.com/

applying [1/1] https://public-inbox.org/git/17fb8d050dae2efd84f090268095da4d04b15c88.1600283416.git.gitgitgadget@gmail.com/
diff --git a/reftable/tree.c b/reftable/tree.c
new file mode 100644
index 0000000000..0061d14e30

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

skipping https://public-inbox.org/git/e30a7e02815121eeba34d7f27b352f675a7d9f60.1601568664.git.gitgitgadget@gmail.com/ for 0061d14e30
skipping https://public-inbox.org/git/24afac9c91a2eaf1529433a136d0f43aeae71550.1606419752.git.gitgitgadget@gmail.com/ for 0061d14e30
skipping https://public-inbox.org/git/6968dbc3828f22369cc92bf56e3a7855769415fa.1607522429.git.gitgitgadget@gmail.com/ for 0061d14e30
skipping https://public-inbox.org/git/b6eed7283aac77d65d9127408b0571ab13e46650.1615580397.git.gitgitgadget@gmail.com/ for 0061d14e30
skipping https://public-inbox.org/git/ceddefadd48c772ea124078d59a76d634d1db1be.1618255553.git.gitgitgadget@gmail.com/ for 0061d14e30
skipping https://public-inbox.org/git/86646c834c2d4046aa8734e5330beb827aeb8539.1592335243.git.gitgitgadget@gmail.com/ for 0061d14e30
skipping https://public-inbox.org/git/3c84f43cfa07708759b386f63dc4893ac45d0850.1592862921.git.gitgitgadget@gmail.com/ for 0061d14e30
skipping https://public-inbox.org/git/169f6c7f543f1d3e5c91a0b38961c765d6900107.1593457018.git.gitgitgadget@gmail.com/ for 0061d14e30
skipping https://public-inbox.org/git/12d98125c2bacdaab797cbaca47bdbfe000c293f.1596209238.git.gitgitgadget@gmail.com/ for 0061d14e30
skipping https://public-inbox.org/git/0bc28ac610fb6f5965e39f9e0d4caf88ca9ead06.1591380199.git.gitgitgadget@gmail.com/ for 0061d14e30
skipping https://public-inbox.org/git/718b646a54e241c0d201fa8ea24fe8838f51ccd7.1590695210.git.gitgitgadget@gmail.com/ for 0061d14e30
index at:
100644 0061d14e306c0a28c77252590173c1c459dac04e	reftable/tree.c

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public 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).