- unsigned i;
- for (i = 0; module->pp_shortcuts[i] != NULL; i++);
- if (i >= (MODULE_SHORTCUT_MAX - 1))
- break;
-
- module->pp_shortcuts[i] = va_arg (ap, char *);
+ unsigned i_shortcuts = va_arg (ap, unsigned);
+ unsigned index = module->i_shortcuts;
+ /* The cache loader accept only a small number of shortcuts */
+ assert(i_shortcuts + index <= MODULE_SHORTCUT_MAX);
+
+ const char *const *tab = va_arg (ap, const char *const *);
+ const char **pp = realloc (module->pp_shortcuts,
+ sizeof (pp[0]) * (index + i_shortcuts));
+ if (unlikely(pp == NULL))
+ {
+ ret = -1;
+ break;
+ }
+ module->pp_shortcuts = pp;
+ module->i_shortcuts = index + i_shortcuts;
+ memcpy (pp + index, tab, sizeof (pp[0]) * i_shortcuts);