diff --git a/src/atom.c b/src/atom.c index bdcd205..4f8b089 100644 --- a/src/atom.c +++ b/src/atom.c @@ -93,6 +93,8 @@ atom_table_new(void) if (!table) return NULL; + darray_init(table->table); + darray_growalloc(table->table, 100); darray_append(table->table, NULL); return table; diff --git a/src/darray.h b/src/darray.h index 6c21bbf..2547b47 100644 --- a/src/darray.h +++ b/src/darray.h @@ -280,7 +280,7 @@ typedef darray(unsigned long) darray_ulong; static inline size_t darray_next_alloc(size_t alloc, size_t need) { if (alloc == 0) - alloc = 1; + alloc = 4; while (alloc < need) alloc *= 2; return alloc; diff --git a/src/xkbcomp/rules.c b/src/xkbcomp/rules.c index 14c3c68..244701d 100644 --- a/src/xkbcomp/rules.c +++ b/src/xkbcomp/rules.c @@ -992,10 +992,13 @@ load_rules(FILE *file) rules = calloc(1, sizeof(*rules)); if (!rules) return NULL; + darray_init(rules->rules); + darray_growalloc(rules->rules, 16); memset(&mapping, 0, sizeof(mapping)); memset(&tgroup, 0, sizeof(tgroup)); darray_init(line); + darray_growalloc(line, 128); while (input_line_get(file, &line)) { if (match_line(&line, &mapping, &trule, &tgroup)) { diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c index a61a52b..823223d 100644 --- a/src/xkbcomp/symbols.c +++ b/src/xkbcomp/symbols.c @@ -256,8 +256,6 @@ typedef struct _ModMapEntry } u; } ModMapEntry; -#define SYMBOLS_INIT_SIZE 110 - typedef struct _SymbolsInfo { char *name; /* e.g. pc+us+inet(evdev) */ @@ -286,7 +284,7 @@ InitSymbolsInfo(SymbolsInfo * info, struct xkb_keymap *keymap) info->fileID = 0; info->merge = MergeOverride; darray_init(info->keys); - darray_growalloc(info->keys, SYMBOLS_INIT_SIZE); + darray_growalloc(info->keys, 110); info->modMap = NULL; for (i = 0; i < XkbNumKbdGroups; i++) info->groupNames[i] = XKB_ATOM_NONE;