Skip to content

Commit

Permalink
internal: util: add UTIL_IN_SET
Browse files Browse the repository at this point in the history
  • Loading branch information
prajnoha committed Dec 13, 2023
1 parent 35f4965 commit e52b928
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/include/internal/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@ extern "C" {
(b) = tmp; \
} while (0)

#define UTIL_IN_SET(a, ...) \
({ \
typeof(a) _arr[] = {__VA_ARGS__}; \
int _found = 0; \
for (unsigned int _i = 0; _i < sizeof(_arr) / sizeof(_arr[0]); _i++) { \
if (a == _arr[_i]) { \
_found = 1; \
break; \
} \
} \
_found; \
})

/*
* All functions that need to use allocated memory and they provide a
* possibility to use preallocated memory contain 'util_mem_t *mem'
Expand Down

0 comments on commit e52b928

Please sign in to comment.