diff options
author | Jordan Augé <jordan.auge+fdio@cisco.com> | 2019-10-23 17:55:00 +0200 |
---|---|---|
committer | Jordan Augé <jordan.auge+fdio@cisco.com> | 2019-10-24 00:21:47 +0200 |
commit | 8e12c8e42cc9ea9d12e55a3a0d8fbcb211504c04 (patch) | |
tree | 1556919c967bd1b6ea664c1f80d6d43efb805f59 /ctrl/facemgr/src/util/set.h | |
parent | cf3d6ef0cbda50c9917421213a77097250f3d67b (diff) |
[HICN-352] facemgr event loop enhancement; timer support & async hicn-light interface
Change-Id: I920a0eb091d826e1eb0d1f786fb0b437487f7ff7
Signed-off-by: Jordan Augé <jordan.auge+fdio@cisco.com>
Diffstat (limited to 'ctrl/facemgr/src/util/set.h')
-rw-r--r-- | ctrl/facemgr/src/util/set.h | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/ctrl/facemgr/src/util/set.h b/ctrl/facemgr/src/util/set.h index 61df209ab..0dad17423 100644 --- a/ctrl/facemgr/src/util/set.h +++ b/ctrl/facemgr/src/util/set.h @@ -24,7 +24,6 @@ //#else #define thread_local _Thread_local //#endif /* ! __ANDROID__ */ -#include "../common.h" #define ERR_SET_EXISTS -2 #define ERR_SET_NOT_FOUND -3 @@ -34,6 +33,13 @@ static inline int +int_cmp(const int x, const int y) +{ + return x - y; +} + +static inline +int int_snprintf(char * buf, size_t size, int value) { return snprintf(buf, size, "%d", value); } @@ -50,6 +56,8 @@ generic_snprintf(char * buf, size_t size, const void * value) { return snprintf(buf, BUFSIZE, "%p", value); } +typedef int(*cmp_t)(const void * x, const void * y); + #define TYPEDEF_SET_H(NAME, T) \ \ typedef struct { \ @@ -87,8 +95,33 @@ NAME ## _initialize(NAME ## _t * set) \ return 0; \ } \ \ -NO_FINALIZE(NAME); \ -AUTOGENERATE_CREATE_FREE(NAME); \ +int \ +NAME ## _finalize(NAME ## _t * set) { return 0; } \ + \ +NAME ## _t * \ +NAME ## _create() \ +{ \ + NAME ## _t * set = malloc(sizeof(NAME ## _t)); \ + if (!set) \ + goto ERR_MALLOC; \ + \ + if (NAME ## _initialize(set) < 0) \ + goto ERR_INITIALIZE; \ + \ + return set; \ + \ +ERR_INITIALIZE: \ + free(set); \ +ERR_MALLOC: \ + return NULL; \ +} \ + \ +void \ +NAME ## _free(NAME ## _t * set) \ +{ \ + NAME ## _finalize(set); \ + free(set); \ +} \ \ int \ NAME ## _add(NAME ## _t * set, const T element) \ |