summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJordan Augé <jordan.auge+fdio@cisco.com>2019-12-10 23:57:37 +0100
committerJordan Augé <jordan.auge+fdio@cisco.com>2019-12-10 23:59:48 +0100
commit2f8f60f943b71e1caab14856c6a03c81e5ba6c9c (patch)
treebfe69da25a7b8b27f67d4206e5ba17a2fb4a1497 /lib
parenta40a23b0d7fc5ebecbb97a5213646add5eeadc5b (diff)
[HICN-438] facemgr should allow face creation with physical interface down
Change-Id: I6487fbec0607464a625daa01455ddac8fdd75ee2 Signed-off-by: Jordan Augé <jordan.auge+fdio@cisco.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/includes/hicn/util/set.h28
1 files changed, 18 insertions, 10 deletions
diff --git a/lib/includes/hicn/util/set.h b/lib/includes/hicn/util/set.h
index c7dd7bf09..b4673a673 100644
--- a/lib/includes/hicn/util/set.h
+++ b/lib/includes/hicn/util/set.h
@@ -77,6 +77,8 @@ int NAME ## _add(NAME ## _t * set, const T element); \
\
int NAME ## _remove(NAME ## _t * set, const T search, T * element); \
\
+int NAME ## _clear(NAME ## _t * set); \
+ \
int NAME ## _get(const NAME ## _t * set, const T search, T * element); \
\
int NAME ## _get_array(const NAME ## _t * set, T ** element); \
@@ -98,16 +100,7 @@ NAME ## _initialize(NAME ## _t * set) \
int \
NAME ## _finalize(NAME ## _t * set) \
{ \
- T * array; \
- int n = NAME ## _get_array(set, &array); \
- if (n < 0) \
- return -1; \
- for (unsigned i = 0; i < n; i++) { \
- T element = array[i]; \
- NAME ## _remove(set, element, NULL); \
- } \
- free(array); \
- return 0; \
+ return NAME ## _clear(set); \
} \
\
NAME ## _t * \
@@ -161,6 +154,21 @@ NAME ## _remove(NAME ## _t * set, const T search, T * element) \
} \
\
int \
+NAME ## _clear(NAME ## _t * set) \
+{ \
+ T * array; \
+ int n = NAME ## _get_array(set, &array); \
+ if (n < 0) \
+ return -1; \
+ for (unsigned i = 0; i < n; i++) { \
+ T element = array[i]; \
+ NAME ## _remove(set, element, NULL); \
+ } \
+ free(array); \
+ return 0; \
+} \
+ \
+int \
NAME ## _get(const NAME ## _t * set, const T search, T * element) \
{ \
T * found = tfind(search, &set->root, (cmp_t)CMP); \