diff options
author | dimitri staessens <dimitri.staessens@intec.ugent.be> | 2017-02-03 15:48:06 +0100 |
---|---|---|
committer | dimitri staessens <dimitri.staessens@intec.ugent.be> | 2017-02-03 15:48:06 +0100 |
commit | 28224928bd4706515afc2885d16ca45389fc81ee (patch) | |
tree | eccc0d16de6d9976bf86acf40b3aa02e857983aa /src/lib | |
parent | d68740d0fd396272d0b2db553a7f33aad5c850e9 (diff) | |
download | ouroboros-28224928bd4706515afc2885d16ca45389fc81ee.tar.gz ouroboros-28224928bd4706515afc2885d16ca45389fc81ee.zip |
lib: Retrieve number of children of a RIB node
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/rib.c | 13 |
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; |