From e44cd2e93b608617bb8b9bfc3aaa1b5e738e9c6a Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Mon, 24 Sep 2012 10:55:20 +0200 Subject: symbols: move keysyms into LevelInfo Instead of maintaining a syms array in the GroupInfo + sym_index's in the levels. This simplifies the code somewhat. In order not to alloc for every level instead of every group, we only do it if the level has more than one keysym (with a union). Since for now this is a special case, it actually works out better memory-wise. Signed-off-by: Ran Benita --- src/utils.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/utils.h') diff --git a/src/utils.h b/src/utils.h index 9f0505c..55ff61c 100644 --- a/src/utils.h +++ b/src/utils.h @@ -82,6 +82,15 @@ strnull(const char *s) return s ? s : "(null)"; } +static inline void * +memdup(const void *mem, size_t nmemb, size_t size) +{ + void *p = malloc(nmemb * size); + if (p) + memcpy(p, mem, nmemb * size); + return p; +} + #define MIN(a, b) ((a) < (b) ? (a) : (b)) #define MIN3(a, b, c) MIN(MIN((a), (b)), (c)) #define MAX(a, b) ((a) > (b) ? (a) : (b)) -- cgit v1.2.3