aboutsummaryrefslogtreecommitdiffstats
path: root/lib/includes/hicn/util/set.h
diff options
context:
space:
mode:
authorJordan Augé <jordan.auge+fdio@cisco.com>2019-11-12 00:15:11 +0100
committerJordan Augé <jordan.auge+fdio@cisco.com>2019-11-17 00:56:51 +0100
commit45bc09ae553e7ac5bf6cd7ab2e77e7f6d0877596 (patch)
tree347cd702a5d3914e003401158b916c709caa302e /lib/includes/hicn/util/set.h
parent547acf3eed92d3564139cccf205c852178bcc310 (diff)
[HICN-395] Static face/route maintainance though face manager
Change-Id: I8f2287a262412bacc50f3c89756ec9fd6ce30d33 Signed-off-by: Jordan Augé <jordan.auge+fdio@cisco.com>
Diffstat (limited to 'lib/includes/hicn/util/set.h')
-rw-r--r--lib/includes/hicn/util/set.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/includes/hicn/util/set.h b/lib/includes/hicn/util/set.h
index c1f43918b..c7dd7bf09 100644
--- a/lib/includes/hicn/util/set.h
+++ b/lib/includes/hicn/util/set.h
@@ -138,10 +138,12 @@ NAME ## _free(NAME ## _t * set) \
int \
NAME ## _add(NAME ## _t * set, const T element) \
{ \
+ T * found = tfind(element, &set->root, (cmp_t)CMP); \
void * ptr = tsearch(element, &set->root, (cmp_t)CMP); \
if (!ptr) \
return -1; \
- set->size++; \
+ if (!found) \
+ set->size++; \
return 0; \
} \
\
@@ -214,7 +216,7 @@ int \
NAME ## _get_array(const NAME ## _t * set, T ** element) \
{ \
if (!element) \
- goto END; \
+ goto END; \
*element = malloc(set->size * sizeof(T)); \
if (!*element) \
return -1; \