utils: detect overflow in memdup()

Signed-off-by: Ran Benita <ran234@gmail.com>
darray: remove unused darray_foreach_reverse()

Signed-off-by: Ran Benita <ran234@gmail.com>
keymap: protect xkb_foreach_key macro params

Signed-off-by: Ran Benita <ran234@gmail.com>
keymap: rename xkb_foreach_key to xkb_keys_foreach

We'll use the format xkb_foos_foreach and xkb_foos_enumerate for the
various iterators.

Signed-off-by: Ran Benita <ran234@gmail.com>
keymap: add and use xkb_mods_{foreach,enumerate}()

To iterate over an xkb_mod_set. Slightly nicer interface and makes
transitioning from darray easier.

Signed-off-by: Ran Benita <ran234@gmail.com>
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>
keymap, keycodes, compat: don't use darray for LEDs

Use a static array of size XKB_MAX_LEDS instead, as in xkb_mod_set.

Signed-off-by: Ran Benita <ran234@gmail.com>