keymap: be more careful in xkb_keymap_unref
To allow calling _unref on the keymap in whatever limbo state it happens to be in. Signed-off-by: Ran Benita <ran234@gmail.com>master
parent
be38862b2a
commit
5f787e5e91
26
src/keymap.c
26
src/keymap.c
|
@ -91,21 +91,27 @@ xkb_keymap_unref(struct xkb_keymap *keymap)
|
|||
|
||||
if (keymap->keys) {
|
||||
xkb_foreach_key(key, keymap) {
|
||||
for (i = 0; i < key->num_groups; i++) {
|
||||
for (j = 0; j < XkbKeyGroupWidth(key, i); j++)
|
||||
if (key->groups[i].levels[j].num_syms > 1)
|
||||
free(key->groups[i].levels[j].u.syms);
|
||||
free(key->groups[i].levels);
|
||||
if (key->groups) {
|
||||
for (i = 0; i < key->num_groups; i++) {
|
||||
if (key->groups[i].levels) {
|
||||
for (j = 0; j < XkbKeyGroupWidth(key, i); j++)
|
||||
if (key->groups[i].levels[j].num_syms > 1)
|
||||
free(key->groups[i].levels[j].u.syms);
|
||||
free(key->groups[i].levels);
|
||||
}
|
||||
}
|
||||
free(key->groups);
|
||||
}
|
||||
free(key->groups);
|
||||
}
|
||||
free(keymap->keys);
|
||||
}
|
||||
for (i = 0; i < keymap->num_types; i++) {
|
||||
free(keymap->types[i].entries);
|
||||
free(keymap->types[i].level_names);
|
||||
if (keymap->types) {
|
||||
for (i = 0; i < keymap->num_types; i++) {
|
||||
free(keymap->types[i].entries);
|
||||
free(keymap->types[i].level_names);
|
||||
}
|
||||
free(keymap->types);
|
||||
}
|
||||
free(keymap->types);
|
||||
free(keymap->sym_interprets);
|
||||
free(keymap->key_aliases);
|
||||
free(keymap->group_names);
|
||||
|
|
Loading…
Reference in New Issue