old->next = new;
return true;
}
-
-/***====================================================================***/
-
-union xkb_action *
-ResizeKeyActions(struct xkb_keymap *keymap, struct xkb_key *key,
- uint32_t needed)
-{
- size_t old_ndx, old_num_acts, new_ndx;
-
- if (needed == 0) {
- key->acts_index = 0;
- return NULL;
- }
-
- if (XkbKeyHasActions(key) && key->width >= needed)
- return XkbKeyActionsPtr(keymap, key);
-
- /*
- * The key may already be in the array, but without enough space.
- * This should not happen often, so in order to avoid moving and
- * copying stuff from acts and key_acts, we just allocate new
- * space for the key at the end, and leave the old space alone.
- */
-
- old_ndx = key->acts_index;
- old_num_acts = XkbKeyNumActions(key);
- new_ndx = darray_size(keymap->acts);
-
- darray_resize0(keymap->acts, new_ndx + needed);
- key->acts_index = new_ndx;
-
- /*
- * The key was already in the array, copy the old actions to the
- * new space.
- */
- if (old_ndx != 0)
- memcpy(darray_mem(keymap->acts, new_ndx),
- darray_mem(keymap->acts, old_ndx),
- old_num_acts * sizeof(union xkb_action));
-
- return XkbKeyActionsPtr(keymap, key);
-}