diff options
author | Jordan Augé <jordan.auge+fdio@cisco.com> | 2019-11-17 09:53:22 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@fd.io> | 2019-11-17 09:53:22 +0000 |
commit | 2dcc25795fab0100ce33852f08d77a5fd90d8f14 (patch) | |
tree | f133b4e05dd4f67588d65d0521349f14f2d38220 /lib/includes/hicn/util/set.h | |
parent | a2efba68e8fc25459ee524e31fc7228ee62d89ce (diff) | |
parent | 45bc09ae553e7ac5bf6cd7ab2e77e7f6d0877596 (diff) |
Merge "[HICN-395] Static face/route maintainance though face manager"
Diffstat (limited to 'lib/includes/hicn/util/set.h')
-rw-r--r-- | lib/includes/hicn/util/set.h | 6 |
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; \ |