diff options
author | Ran Benita <ran234@gmail.com> | 2014-04-22 12:23:36 +0300 |
---|---|---|
committer | Ran Benita <ran234@gmail.com> | 2014-04-22 14:56:44 +0300 |
commit | 787faf36654ed75672613c560286caddadce3ec5 (patch) | |
tree | a3d72f5562234c15141faa3331f6ad1550e0df07 /src/keymap.c | |
parent | 6b1cdee107caaf8009037763a3cc3cd51132a1dd (diff) | |
download | xorg-lib-libxkbcommon-787faf36654ed75672613c560286caddadce3ec5.tar.gz |
keymap: don't use darray in xkb_mod_set
Instead just statically allocate the mods array (of size MAX_MOD_SIZE =
32). The limit is not going anywhere, and static allocations are nicer
(nicer code, no OOM, etc.). It's also small and dense enough.
Signed-off-by: Ran Benita <ran234@gmail.com>
Diffstat (limited to 'src/keymap.c')
-rw-r--r-- | src/keymap.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/keymap.c b/src/keymap.c index dc2541c..0b8bd96 100644 --- a/src/keymap.c +++ b/src/keymap.c @@ -93,7 +93,6 @@ xkb_keymap_unref(struct xkb_keymap *keymap) free(keymap->sym_interprets); free(keymap->key_aliases); free(keymap->group_names); - darray_free(keymap->mods.mods); darray_free(keymap->leds); free(keymap->keycodes_section_name); free(keymap->symbols_section_name); @@ -263,7 +262,7 @@ xkb_keymap_get_as_string(struct xkb_keymap *keymap, XKB_EXPORT xkb_mod_index_t xkb_keymap_num_mods(struct xkb_keymap *keymap) { - return darray_size(keymap->mods.mods); + return keymap->mods.num_mods; } /** @@ -272,11 +271,10 @@ xkb_keymap_num_mods(struct xkb_keymap *keymap) XKB_EXPORT const char * xkb_keymap_mod_get_name(struct xkb_keymap *keymap, xkb_mod_index_t idx) { - if (idx >= darray_size(keymap->mods.mods)) + if (idx >= keymap->mods.num_mods) return NULL; - return xkb_atom_text(keymap->ctx, - darray_item(keymap->mods.mods, idx).name); + return xkb_atom_text(keymap->ctx, keymap->mods.mods[idx].name); } /** |