Enable ctl_lookup() to start from arbitrary node
This commit is contained in:
parent
063a767ffe
commit
91e006c4c2
12
src/ctl.c
12
src/ctl.c
@ -1328,8 +1328,8 @@ label_return:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ctl_lookup(tsdn_t *tsdn, const char *name, ctl_node_t const **nodesp,
|
ctl_lookup(tsdn_t *tsdn, const ctl_named_node_t *starting_node,
|
||||||
size_t *mibp, size_t *depthp) {
|
const char *name, ctl_node_t const **nodesp, size_t *mibp, size_t *depthp) {
|
||||||
int ret;
|
int ret;
|
||||||
const char *elm, *tdot, *dot;
|
const char *elm, *tdot, *dot;
|
||||||
size_t elen, i, j;
|
size_t elen, i, j;
|
||||||
@ -1343,7 +1343,7 @@ ctl_lookup(tsdn_t *tsdn, const char *name, ctl_node_t const **nodesp,
|
|||||||
ret = ENOENT;
|
ret = ENOENT;
|
||||||
goto label_return;
|
goto label_return;
|
||||||
}
|
}
|
||||||
node = super_root_node;
|
node = starting_node;
|
||||||
for (i = 0; i < *depthp; i++) {
|
for (i = 0; i < *depthp; i++) {
|
||||||
assert(node);
|
assert(node);
|
||||||
assert(node->nchildren > 0);
|
assert(node->nchildren > 0);
|
||||||
@ -1440,7 +1440,8 @@ ctl_byname(tsd_t *tsd, const char *name, void *oldp, size_t *oldlenp,
|
|||||||
}
|
}
|
||||||
|
|
||||||
depth = CTL_MAX_DEPTH;
|
depth = CTL_MAX_DEPTH;
|
||||||
ret = ctl_lookup(tsd_tsdn(tsd), name, nodes, mib, &depth);
|
ret = ctl_lookup(tsd_tsdn(tsd), super_root_node, name, nodes, mib,
|
||||||
|
&depth);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
goto label_return;
|
goto label_return;
|
||||||
}
|
}
|
||||||
@ -1466,7 +1467,8 @@ ctl_nametomib(tsd_t *tsd, const char *name, size_t *mibp, size_t *miblenp) {
|
|||||||
goto label_return;
|
goto label_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = ctl_lookup(tsd_tsdn(tsd), name, NULL, mibp, miblenp);
|
ret = ctl_lookup(tsd_tsdn(tsd), super_root_node, name, NULL, mibp,
|
||||||
|
miblenp);
|
||||||
label_return:
|
label_return:
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user