From 2f8f60f943b71e1caab14856c6a03c81e5ba6c9c Mon Sep 17 00:00:00 2001 From: Jordan Augé Date: Tue, 10 Dec 2019 23:57:37 +0100 Subject: [HICN-438] facemgr should allow face creation with physical interface down MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I6487fbec0607464a625daa01455ddac8fdd75ee2 Signed-off-by: Jordan Augé --- lib/includes/hicn/util/set.h | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'lib') 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); \ -- cgit 1.2.3-korg