summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRan Benita <ran234@gmail.com>2012-06-06 10:01:43 +0300
committerRan Benita <ran234@gmail.com>2012-06-09 13:21:21 +0300
commita1f8440d700c7a0b10494d0183fb92b66bda54e3 (patch)
tree335fa5d001c6e086f225edbe7a4e336d75cacac9 /src
parent54bdfd05a4f30397a4cb4ee1608f2c8d82416b00 (diff)
symbols: use darray in struct xkb_sym_map
Signed-off-by: Ran Benita <ran234@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/alloc.c16
-rw-r--r--src/xkb-priv.h5
-rw-r--r--src/xkbcomp/symbols.c2
3 files changed, 5 insertions, 18 deletions
diff --git a/src/alloc.c b/src/alloc.c
index d0b0618..d474a64 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -158,19 +158,7 @@ bool
XkbcResizeKeySyms(struct xkb_keymap *keymap, xkb_keycode_t key,
unsigned int needed)
{
- struct xkb_sym_map *sym_map = &darray_item(keymap->map->key_sym_map, key);
-
- if (sym_map->size_syms >= needed)
- return true;
-
- sym_map->syms = uTypedRecalloc(sym_map->syms, sym_map->size_syms,
- needed, xkb_keysym_t);
- if (!sym_map->syms) {
- sym_map->size_syms = 0;
- return false;
- }
-
- sym_map->size_syms = needed;
+ darray_resize0(darray_item(keymap->map->key_sym_map, key).syms, needed);
return true;
}
@@ -241,7 +229,7 @@ XkbcFreeClientMap(struct xkb_keymap *keymap)
darray_foreach(sym_map, map->key_sym_map) {
free(sym_map->sym_index);
free(sym_map->num_syms);
- free(sym_map->syms);
+ darray_free(sym_map->syms);
}
darray_free(map->key_sym_map);
diff --git a/src/xkb-priv.h b/src/xkb-priv.h
index 6493aea..e421fd9 100644
--- a/src/xkb-priv.h
+++ b/src/xkb-priv.h
@@ -274,8 +274,7 @@ struct xkb_sym_map {
unsigned char width;
int *sym_index; /* per level/group index into 'syms' */
unsigned int *num_syms; /* per level/group */
- xkb_keysym_t *syms;
- unsigned int size_syms; /* size of 'syms' */
+ darray(xkb_keysym_t) syms;
};
struct xkb_client_map {
@@ -389,7 +388,7 @@ struct xkb_keymap {
#define XkbKeyNumSyms(d, k, g, sl) \
(darray_item((d)->map->key_sym_map, k).num_syms[(g * XkbKeyGroupsWidth(d, k)) + sl])
#define XkbKeySym(d, k, n) \
- (&darray_item((d)->map->key_sym_map, k).syms[n])
+ (&darray_item(darray_item((d)->map->key_sym_map, k).syms, n))
#define XkbKeySymOffset(d, k, g, sl) \
(darray_item((d)->map->key_sym_map, k).sym_index[(g * XkbKeyGroupsWidth(d, k)) + sl])
#define XkbKeySymEntry(d, k, g, sl) \
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index f3b16ec..f464416 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -1942,7 +1942,7 @@ CopySymbolsDef(struct xkb_keymap *keymap, KeyInfo *key, int start_from)
if (tmp < key->numLevels[i] &&
darray_item(key->symsMapNumEntries[i], tmp) != 0)
{
- memcpy(&sym_map->syms[symIndex],
+ memcpy(darray_mem(sym_map->syms, symIndex),
darray_mem(key->syms[i],
darray_item(key->symsMapIndex[i], tmp)),
darray_item(key->symsMapNumEntries[i], tmp) * sizeof(xkb_keysym_t));