diff options
author | Ran Benita <ran234@gmail.com> | 2012-09-24 10:55:20 +0200 |
---|---|---|
committer | Ran Benita <ran234@gmail.com> | 2012-09-24 12:33:06 +0200 |
commit | e44cd2e93b608617bb8b9bfc3aaa1b5e738e9c6a (patch) | |
tree | 6ac6d10fc5c76ba0af52a562e488c0e06e88d31b /src/utils.h | |
parent | eaf9515229289b1ad1f7d8f202b2a66d735ef36a (diff) | |
download | libxkbcommon-e44cd2e93b608617bb8b9bfc3aaa1b5e738e9c6a.tar.gz libxkbcommon-e44cd2e93b608617bb8b9bfc3aaa1b5e738e9c6a.tar.bz2 libxkbcommon-e44cd2e93b608617bb8b9bfc3aaa1b5e738e9c6a.zip |
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 <ran234@gmail.com>
Diffstat (limited to 'src/utils.h')
-rw-r--r-- | src/utils.h | 9 |
1 files changed, 9 insertions, 0 deletions
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)) |