summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@intec.ugent.be>2017-02-03 14:57:27 +0000
committerSander Vrijders <sander.vrijders@intec.ugent.be>2017-02-03 14:57:27 +0000
commitc677d8a88065e6bc8e071f3f03a440e4ed083abb (patch)
treeeccc0d16de6d9976bf86acf40b3aa02e857983aa /src
parente120bf4eb796fba8aff5e11a3ccf49e8769605fb (diff)
parent28224928bd4706515afc2885d16ca45389fc81ee (diff)
downloadouroboros-c677d8a88065e6bc8e071f3f03a440e4ed083abb.tar.gz
ouroboros-c677d8a88065e6bc8e071f3f03a440e4ed083abb.zip
Merged in dstaesse/ouroboros/be-wip (pull request #358)
lib: Retrieve number of children of a RIB node
Diffstat (limited to 'src')
-rw-r--r--src/lib/rib.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/lib/rib.c b/src/lib/rib.c
index 31ab372f..e0456b6f 100644
--- a/src/lib/rib.c
+++ b/src/lib/rib.c
@@ -690,7 +690,8 @@ bool rib_has(const char * path)
{
struct rnode * node;
- assert(path);
+ if (path == NULL)
+ return -EINVAL;
pthread_rwlock_rdlock(&rib.lock);
@@ -710,8 +711,8 @@ ssize_t rib_children(const char * path,
ssize_t i = 0;
- assert(path);
- assert(children);
+ if (path == NULL)
+ return -EINVAL;
pthread_rwlock_rdlock(&rib.lock);
@@ -721,6 +722,12 @@ ssize_t rib_children(const char * path,
return -EPERM;
}
+ if (children == NULL) {
+ pthread_rwlock_unlock(&rib.lock);
+ assert((ssize_t) node->chlen >= 0);
+ return (ssize_t) node->chlen;
+ }
+
if (node->chlen == 0) {
pthread_rwlock_unlock(&rib.lock);
*children = NULL;