Commit 1313af8fb50899e344356b2126d1e4fffa5c8659

Ran Benita 2012-07-15T01:31:34

Get rid of xkb_key_names Signed-off-by: Ran Benita <ran234@gmail.com>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
diff --git a/src/alloc.c b/src/alloc.c
index 08f8813..8441f52 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -145,80 +145,27 @@ free_sym_maps(struct xkb_keymap *keymap)
     darray_free(keymap->key_sym_map);
 }
 
-int
-XkbcAllocNames(struct xkb_keymap *keymap, unsigned which,
-               size_t nTotalAliases)
-{
-    if (!keymap)
-        return BadMatch;
-
-    if (!keymap->names) {
-        keymap->names = calloc(1, sizeof(*keymap->names));
-        if (!keymap->names)
-            return BadAlloc;
-
-        darray_init(keymap->names->keys);
-        darray_init(keymap->names->key_aliases);
-    }
-
-    if ((which & XkbKTLevelNamesMask) && keymap) {
-        struct xkb_key_type * type;
-
-        darray_foreach(type, keymap->types) {
-            if (!type->level_names) {
-                type->level_names = calloc(type->num_levels,
-                                           sizeof(*type->level_names));
-                if (!type->level_names)
-                    return BadAlloc;
-            }
-        }
-    }
-
-    if (which & XkbKeyNamesMask)
-        darray_resize0(keymap->names->keys, keymap->max_key_code + 1);
-
-    if (which & XkbKeyAliasesMask)
-        darray_resize0(keymap->names->key_aliases, nTotalAliases);
-
-    return Success;
-}
-
 static void
-XkbcFreeNames(struct xkb_keymap *keymap)
+free_names(struct xkb_keymap *keymap)
 {
-    struct xkb_names * names;
-    struct xkb_key_type *type;
     int i;
 
-    if (!keymap || !keymap->names)
-        return;
-
-    names = keymap->names;
-
-    darray_foreach(type, keymap->types) {
-        int j;
-        for (j = 0; j < type->num_levels; j++)
-            free(type->level_names[j]);
-        free(type->level_names);
-        type->level_names = NULL;
-    }
-
-    free(names->keycodes);
-    free(names->symbols);
-    free(names->keytypes);
-    free(names->compat);
-
     for (i = 0; i < XkbNumVirtualMods; i++)
-        free(names->vmods[i]);
+        free(keymap->vmod_names[i]);
+
     for (i = 0; i < XkbNumIndicators; i++)
-        free(names->indicators[i]);
+        free(keymap->indicator_names[i]);
+
     for (i = 0; i < XkbNumKbdGroups; i++)
-        free(names->groups[i]);
+        free(keymap->group_names[i]);
+
+    darray_free(keymap->key_names);
+    darray_free(keymap->key_aliases);
 
-    darray_free(names->keys);
-    darray_free(names->key_aliases);
-    free(names);
-    keymap->names = NULL;
+    free(keymap->keycodes_section_name);
+    free(keymap->symbols_section_name);
+    free(keymap->types_section_name);
+    free(keymap->compat_section_name);
 }
 
 int
@@ -281,7 +228,7 @@ XkbcFreeKeyboard(struct xkb_keymap *keymap)
     free(keymap->behaviors);
     free(keymap->vmodmap);
     darray_free(keymap->sym_interpret);
-    XkbcFreeNames(keymap);
+    free_names(keymap);
     XkbcFreeControls(keymap);
     xkb_context_unref(keymap->ctx);
     free(keymap);
diff --git a/src/alloc.h b/src/alloc.h
index b1ee0d4..a525990 100644
--- a/src/alloc.h
+++ b/src/alloc.h
@@ -30,10 +30,6 @@
 #include "xkb-priv.h"
 
 extern int
-XkbcAllocNames(struct xkb_keymap *keymap, unsigned which,
-               size_t nTotalAliases);
-
-extern int
 XkbcAllocControls(struct xkb_keymap *keymap);
 
 extern struct xkb_keymap *
diff --git a/src/keymap-dump.c b/src/keymap-dump.c
index e321220..8599d2f 100644
--- a/src/keymap-dump.c
+++ b/src/keymap-dump.c
@@ -125,13 +125,13 @@ write_vmods(struct xkb_keymap *keymap, char **buf, size_t *size,
     int i;
 
     for (i = 0; i < XkbNumVirtualMods; i++) {
-        if (!keymap->names->vmods[i])
+        if (!keymap->vmod_names[i])
             continue;
         if (num_vmods == 0)
             write_buf(keymap, buf, size, offset, "\t\tvirtual_modifiers ");
         else
             write_buf(keymap, buf, size, offset, ",");
-        write_buf(keymap, buf, size, offset, "%s", keymap->names->vmods[i]);
+        write_buf(keymap, buf, size, offset, "%s", keymap->vmod_names[i]);
         num_vmods++;
     }
 
@@ -209,10 +209,10 @@ get_mod_mask_text(struct xkb_keymap *keymap, uint8_t real_mods,
             continue;
         if (ret[0] != '\0') {
             strcpy(ret2, ret);
-            append_get_text("%s+%s", ret2, keymap->names->vmods[i]);
+            append_get_text("%s+%s", ret2, keymap->vmod_names[i]);
         }
         else {
-            append_get_text("%s", keymap->names->vmods[i]);
+            append_get_text("%s", keymap->vmod_names[i]);
         }
     }
 
@@ -313,9 +313,9 @@ write_keycodes(struct xkb_keymap *keymap, char **buf, size_t *size,
     struct xkb_key_alias *alias;
     int i;
 
-    if (keymap->names->keycodes)
+    if (keymap->keycodes_section_name)
         write_buf(keymap, buf, size, offset, "\txkb_keycodes \"%s\" {\n",
-                  keymap->names->keycodes);
+                  keymap->keycodes_section_name);
     else
         write_buf(keymap, buf, size, offset, "\txkb_keycodes {\n");
 
@@ -325,25 +325,26 @@ write_keycodes(struct xkb_keymap *keymap, char **buf, size_t *size,
               keymap->max_key_code);
 
     for (key = keymap->min_key_code; key <= keymap->max_key_code; key++) {
-        if (darray_item(keymap->names->keys, key).name[0] == '\0')
+        if (darray_item(keymap->key_names, key).name[0] == '\0')
             continue;
 
         write_buf(keymap, buf, size, offset, "\t\t%6s = %d;\n",
-                  XkbcKeyNameText(darray_item(keymap->names->keys, key).name),
+                  XkbcKeyNameText(darray_item(keymap->key_names, key).name),
                   key);
     }
 
     for (i = 0; i < XkbNumIndicators; i++) {
-        if (!keymap->names->indicators[i])
+        if (!keymap->indicator_names[i])
             continue;
         write_buf(keymap, buf, size, offset, "\t\tindicator %d = \"%s\";\n",
-                  i + 1, keymap->names->indicators[i]);
+                  i + 1, keymap->indicator_names[i]);
     }
 
-    darray_foreach(alias, keymap->names->key_aliases)
-    write_buf(keymap, buf, size, offset, "\t\talias %6s = %6s;\n",
-              XkbcKeyNameText(alias->alias),
-              XkbcKeyNameText(alias->real));
+
+    darray_foreach(alias, keymap->key_aliases)
+        write_buf(keymap, buf, size, offset, "\t\talias %6s = %6s;\n",
+                  XkbcKeyNameText(alias->alias),
+                  XkbcKeyNameText(alias->real));
 
     write_buf(keymap, buf, size, offset, "\t};\n\n");
     return true;
@@ -356,9 +357,9 @@ write_types(struct xkb_keymap *keymap, char **buf, size_t *size,
     int n;
     struct xkb_key_type *type;
 
-    if (keymap->names->keytypes)
+    if (keymap->types_section_name)
         write_buf(keymap, buf, size, offset, "\txkb_types \"%s\" {\n\n",
-                  keymap->names->keytypes);
+                  keymap->types_section_name);
     else
         write_buf(keymap, buf, size, offset, "\txkb_types {\n\n");
 
@@ -412,7 +413,7 @@ write_indicator_map(struct xkb_keymap *keymap, char **buf, size_t *size,
     struct xkb_indicator_map *led = &keymap->indicators[num];
 
     write_buf(keymap, buf, size, offset, "\t\tindicator \"%s\" {\n",
-              keymap->names->indicators[num]);
+              keymap->indicator_names[num]);
 
     if (led->which_groups) {
         if (led->which_groups != XkbIM_UseEffective) {
@@ -665,10 +666,10 @@ write_compat(struct xkb_keymap *keymap, char **buf, size_t *size,
     int i;
     struct xkb_sym_interpret *interp;
 
-    if (keymap->names->compat)
+    if (keymap->compat_section_name)
         write_buf(keymap, buf, size, offset,
                   "\txkb_compatibility \"%s\" {\n\n",
-                  keymap->names->compat);
+                  keymap->compat_section_name);
     else
         write_buf(keymap, buf, size, offset, "\txkb_compatibility {\n\n");
 
@@ -695,7 +696,7 @@ write_compat(struct xkb_keymap *keymap, char **buf, size_t *size,
         if (interp->virtual_mod != XkbNoModifier) {
             write_buf(keymap, buf, size, offset,
                       "\t\t\tvirtualModifier= %s;\n",
-                      keymap->names->vmods[interp->virtual_mod]);
+                      keymap->vmod_names[interp->virtual_mod]);
         }
 
         if (interp->match & XkbSI_LevelOneOnly)
@@ -783,18 +784,18 @@ write_symbols(struct xkb_keymap *keymap, char **buf, size_t *size,
     int group, tmp;
     bool showActions;
 
-    if (keymap->names->symbols)
+    if (keymap->symbols_section_name)
         write_buf(keymap, buf, size, offset, "\txkb_symbols \"%s\" {\n\n",
-                  keymap->names->symbols);
+                  keymap->symbols_section_name);
     else
         write_buf(keymap, buf, size, offset, "\txkb_symbols {\n\n");
 
     for (tmp = group = 0; group < XkbNumKbdGroups; group++) {
-        if (!keymap->names->groups[group])
+        if (!keymap->group_names[group])
             continue;
         write_buf(keymap, buf, size, offset,
                   "\t\tname[group%d]=\"%s\";\n", group + 1,
-                  keymap->names->groups[group]);
+                  keymap->group_names[group]);
         tmp++;
     }
     if (tmp > 0)
@@ -807,7 +808,7 @@ write_symbols(struct xkb_keymap *keymap, char **buf, size_t *size,
             continue;
 
         write_buf(keymap, buf, size, offset, "\t\tkey %6s {",
-                  XkbcKeyNameText(darray_item(keymap->names->keys, key).name));
+                  XkbcKeyNameText(darray_item(keymap->key_names, key).name));
         if (keymap->explicit) {
             if ((keymap->explicit[key] & XkbExplicitKeyTypesMask)) {
                 bool multi_type = false;
@@ -934,7 +935,7 @@ write_symbols(struct xkb_keymap *keymap, char **buf, size_t *size,
                 write_buf(keymap, buf, size, offset,
                           "\t\tmodifier_map %s { %s };\n",
                           get_mod_index_text(mod),
-                          XkbcKeyNameText(darray_item(keymap->names->keys,
+                          XkbcKeyNameText(darray_item(keymap->key_names,
                                                       key).name));
             }
         }
diff --git a/src/map.c b/src/map.c
index 0190647..4fa5876 100644
--- a/src/map.c
+++ b/src/map.c
@@ -60,7 +60,7 @@ xkb_map_num_mods(struct xkb_keymap *keymap)
     xkb_mod_index_t i;
 
     for (i = 0; i < XkbNumVirtualMods; i++)
-        if (!keymap->names->vmods[i])
+        if (!keymap->vmod_names[i])
             break;
 
     /* We always have all the core modifiers (for now), plus any virtual
@@ -100,7 +100,7 @@ xkb_map_mod_get_name(struct xkb_keymap *keymap, xkb_mod_index_t idx)
     }
 
     /* If that fails, try to find a virtual mod name. */
-    return keymap->names->vmods[idx - Mod5MapIndex];
+    return keymap->vmod_names[idx - Mod5MapIndex];
 }
 
 /**
@@ -128,8 +128,8 @@ xkb_map_mod_get_index(struct xkb_keymap *keymap, const char *name)
     if (strcasecmp(name, "Mod5") == 0)
         return Mod5MapIndex;
 
-    for (i = 0; i < XkbNumVirtualMods && keymap->names->vmods[i]; i++) {
-        if (strcasecmp(name, keymap->names->vmods[i]) == 0)
+    for (i = 0; i < XkbNumVirtualMods && keymap->vmod_names[i]; i++) {
+        if (strcasecmp(name, keymap->vmod_names[i]) == 0)
             return i + Mod5MapIndex;
     }
 
@@ -161,7 +161,7 @@ xkb_map_group_get_name(struct xkb_keymap *keymap, xkb_group_index_t idx)
     if (idx >= xkb_map_num_groups(keymap))
         return NULL;
 
-    return keymap->names->groups[idx];
+    return keymap->group_names[idx];
 }
 
 /**
@@ -174,7 +174,7 @@ xkb_map_group_get_index(struct xkb_keymap *keymap, const char *name)
     xkb_group_index_t i;
 
     for (i = 0; i < num_groups; i++) {
-        if (strcasecmp(keymap->names->groups[i], name) == 0)
+        if (strcasecmp(keymap->group_names[i], name) == 0)
             return i;
     }
 
@@ -217,7 +217,7 @@ xkb_map_led_get_name(struct xkb_keymap *keymap, xkb_led_index_t idx)
     if (idx >= xkb_map_num_leds(keymap))
         return NULL;
 
-    return keymap->names->indicators[idx];
+    return keymap->indicator_names[idx];
 }
 
 /**
@@ -230,7 +230,7 @@ xkb_map_led_get_index(struct xkb_keymap *keymap, const char *name)
     xkb_led_index_t i;
 
     for (i = 0; i < num_leds; i++) {
-        if (strcasecmp(keymap->names->indicators[i], name) == 0)
+        if (strcasecmp(keymap->indicator_names[i], name) == 0)
             return i;
     }
 
diff --git a/src/text.c b/src/text.c
index b9f2b37..a691ede 100644
--- a/src/text.c
+++ b/src/text.c
@@ -56,9 +56,9 @@ XkbcVModIndexText(struct xkb_keymap *keymap, unsigned ndx)
     char buf[20];
 
     if (ndx >= XkbNumVirtualMods)
-        tmp = "illegal";
-    else if (keymap && keymap->names)
-        tmp = keymap->names->vmods[ndx];
+         tmp = "illegal";
+    else
+         tmp = keymap->vmod_names[ndx];
 
     if (!tmp) {
         snprintf(buf, sizeof(buf) - 1, "%d", ndx);
diff --git a/src/xkb-priv.h b/src/xkb-priv.h
index 6d39358..9463b1c 100644
--- a/src/xkb-priv.h
+++ b/src/xkb-priv.h
@@ -293,20 +293,6 @@ struct xkb_key_alias {
     char alias[XkbKeyNameLength];
 };
 
-struct xkb_names {
-    char *keycodes;
-    char *symbols;
-    char *keytypes;
-    char *compat;
-
-    char *vmods[XkbNumVirtualMods];
-    char *indicators[XkbNumIndicators];
-    char *groups[XkbNumKbdGroups];
-
-    darray(struct xkb_key_name) keys;
-    darray(struct xkb_key_alias) key_aliases;
-};
-
 struct xkb_controls {
     /* unsigned char groups_wrap; */
     /* struct xkb_mods internal; */
@@ -335,7 +321,11 @@ struct xkb_keymap {
     xkb_keycode_t max_key_code;
 
     struct xkb_controls *      ctrls;
-    struct xkb_names *        names;
+
+    /* key -> key name mapping */
+    darray(struct xkb_key_name) key_names;
+    /* aliases in no particular order */
+    darray(struct xkb_key_alias) key_aliases;
 
     /* key -> explicit flags mapping */
     unsigned char *explicit;
@@ -349,12 +339,14 @@ struct xkb_keymap {
 
     /* key -> mod mapping */
     unsigned char *modmap;
-    /* vmod -> mod mapping */
-    uint32_t vmods[XkbNumVirtualMods];
     /* key -> vmod mapping */
     uint32_t *vmodmap;
+    /* vmod -> mod mapping */
+    uint32_t vmods[XkbNumVirtualMods];
+    char *vmod_names[XkbNumVirtualMods];
 
     struct xkb_mods groups[XkbNumKbdGroups];
+    char *group_names[XkbNumKbdGroups];
 
     /* key -> actions mapping: acts[key_acts[keycode]] */
     darray(union xkb_action) acts;
@@ -364,6 +356,12 @@ struct xkb_keymap {
     struct xkb_behavior *behaviors;
 
     struct xkb_indicator_map indicators[XkbNumIndicators];
+    char *indicator_names[XkbNumIndicators];
+
+    char *keycodes_section_name;
+    char *symbols_section_name;
+    char *types_section_name;
+    char *compat_section_name;
 };
 
 #define XkbNumGroups(g)             ((g) & 0x0f)
diff --git a/src/xkbcomp/alias.c b/src/xkbcomp/alias.c
index 922e54e..4be638c 100644
--- a/src/xkbcomp/alias.c
+++ b/src/xkbcomp/alias.c
@@ -145,12 +145,11 @@ ApplyAliases(struct xkb_keymap *keymap, AliasInfo ** info_in)
     struct xkb_key_alias *old, *a;
     AliasInfo *info;
     int nNew, nOld;
-    int status;
 
     if (*info_in == NULL)
         return true;
-    nOld = (keymap->names ? darray_size(keymap->names->key_aliases) : 0);
-    old = (keymap->names ? &darray_item(keymap->names->key_aliases, 0) : NULL);
+    nOld = (keymap ? darray_size(keymap->key_aliases) : 0);
+    old = (keymap ? &darray_item(keymap->key_aliases, 0) : NULL);
     for (nNew = 0, info = *info_in; info != NULL;
          info = (AliasInfo *) info->def.next) {
         unsigned long lname;
@@ -200,14 +199,10 @@ ApplyAliases(struct xkb_keymap *keymap, AliasInfo ** info_in)
         return true;
     }
 
-    status = XkbcAllocNames(keymap, XkbKeyAliasesMask, nOld + nNew);
-    if (status != Success) {
-        WSGO("Allocation failure in ApplyAliases\n");
-        return false;
-    }
-    a = keymap->names ? &darray_item(keymap->names->key_aliases, nOld) : NULL;
-    for (info = *info_in; info != NULL; info =
-             (AliasInfo *) info->def.next) {
+    darray_resize0(keymap->key_aliases, nOld + nNew);
+
+    a = keymap ? &darray_item(keymap->key_aliases, nOld) : NULL;
+    for (info = *info_in; info != NULL; info = (AliasInfo *) info->def.next) {
         if (info->alias[0] != '\0') {
             strncpy(a->alias, info->alias, XkbKeyNameLength);
             strncpy(a->real, info->real, XkbKeyNameLength);
diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c
index 2fd83a3..01dfde3 100644
--- a/src/xkbcomp/compat.c
+++ b/src/xkbcomp/compat.c
@@ -739,11 +739,8 @@ CompileCompatMap(XkbFile *file, struct xkb_keymap *keymap,
     darray_init(keymap->sym_interpret);
     darray_growalloc(keymap->sym_interpret, info.nInterps);
 
-    if (info.name) {
-        if (XkbcAllocNames(keymap, 0, 0) != Success)
-            goto err_info;
-        keymap->names->compat = strdup(info.name);
-    }
+    if (info.name)
+        keymap->compat_section_name = strdup(info.name);
 
     if (info.nInterps > 0) {
         CopyInterps(&info, keymap, true, XkbSI_Exactly);
diff --git a/src/xkbcomp/indicators.c b/src/xkbcomp/indicators.c
index d6e40f7..c7f0958 100644
--- a/src/xkbcomp/indicators.c
+++ b/src/xkbcomp/indicators.c
@@ -338,37 +338,35 @@ BindIndicators(struct xkb_keymap *keymap, LEDInfo *unbound)
     int i;
     LEDInfo *led, *next, *last;
 
-    if (keymap->names != NULL) {
-        for (led = unbound; led != NULL; led = (LEDInfo *) led->defs.next) {
-            if (led->indicator == _LED_NotBound) {
-                for (i = 0; i < XkbNumIndicators; i++) {
-                    if (keymap->names->indicators[i] &&
-                        strcmp(keymap->names->indicators[i],
-                               xkb_atom_text(keymap->ctx, led->name)) == 0) {
-                        led->indicator = i + 1;
-                        break;
-                    }
+    for (led = unbound; led != NULL; led = (LEDInfo *) led->defs.next) {
+        if (led->indicator == _LED_NotBound) {
+            for (i = 0; i < XkbNumIndicators; i++) {
+                if (keymap->indicator_names[i] &&
+                    strcmp(keymap->indicator_names[i],
+                           xkb_atom_text(keymap->ctx, led->name)) == 0) {
+                    led->indicator = i + 1;
+                    break;
                 }
             }
         }
-        for (led = unbound; led != NULL; led = (LEDInfo *) led->defs.next) {
-            if (led->indicator == _LED_NotBound) {
-                for (i = 0; i < XkbNumIndicators; i++) {
-                    if (keymap->names->indicators[i] == NULL) {
-                        keymap->names->indicators[i] =
-                            xkb_atom_strdup(keymap->ctx, led->name);
-                        led->indicator = i + 1;
-                        break;
-                    }
-                }
-                if (led->indicator == _LED_NotBound) {
-                    ERROR("No unnamed indicators found\n");
-                    ACTION
-                        ("Virtual indicator map \"%s\" not bound\n",
-                        xkb_atom_text(keymap->ctx, led->name));
-                    continue;
+    }
+
+    for (led = unbound; led != NULL; led = (LEDInfo *) led->defs.next) {
+        if (led->indicator == _LED_NotBound) {
+            for (i = 0; i < XkbNumIndicators; i++) {
+                if (keymap->indicator_names[i] == NULL) {
+                    keymap->indicator_names[i] =
+                        xkb_atom_strdup(keymap->ctx, led->name);
+                    led->indicator = i + 1;
+                    break;
                 }
             }
+            if (led->indicator == _LED_NotBound) {
+                ERROR("No unnamed indicators found\n");
+                ACTION("Virtual indicator map \"%s\" not bound\n",
+                       xkb_atom_text(keymap->ctx, led->name));
+                continue;
+            }
         }
     }
     for (last = NULL, led = unbound; led != NULL; led = next) {
@@ -378,11 +376,9 @@ BindIndicators(struct xkb_keymap *keymap, LEDInfo *unbound)
             free(led);
         }
         else {
-            if ((keymap->names != NULL) &&
-                (strcmp(keymap->names->indicators[led->indicator - 1],
-                        xkb_atom_text(keymap->ctx, led->name)) != 0)) {
-                const char *old =
-                    keymap->names->indicators[led->indicator - 1];
+            if (strcmp(keymap->indicator_names[led->indicator - 1],
+                       xkb_atom_text(keymap->ctx, led->name)) != 0) {
+                const char *old = keymap->indicator_names[led->indicator - 1];
                 ERROR("Multiple names bound to indicator %d\n",
                       (unsigned int) led->indicator);
                 ACTION("Using %s, ignoring %s\n", old,
@@ -424,11 +420,6 @@ CopyIndicatorMapDefs(struct xkb_keymap *keymap, LEDInfo *leds)
     LEDInfo *led, *next;
     LEDInfo *unbound = NULL, *last = NULL;
 
-    if (XkbcAllocNames(keymap, XkbIndicatorNamesMask, 0) != Success) {
-        WSGO("Couldn't allocate names\n");
-        ACTION("Indicator names may be incorrect\n");
-    }
-
     for (led = leds; led != NULL; led = next) {
         next = (LEDInfo *) led->defs.next;
         if ((led->groups != 0) && (led->which_groups == 0))
@@ -454,11 +445,9 @@ CopyIndicatorMapDefs(struct xkb_keymap *keymap, LEDInfo *leds)
             im->mods.real_mods = led->real_mods;
             im->mods.vmods = led->vmods;
             im->ctrls = led->ctrls;
-            if (keymap->names != NULL) {
-                free(keymap->names->indicators[led->indicator - 1]);
-                keymap->names->indicators[led->indicator - 1] =
-                    xkb_atom_strdup(keymap->ctx, led->name);
-            }
+            free(keymap->indicator_names[led->indicator - 1]);
+            keymap->indicator_names[led->indicator - 1] =
+                xkb_atom_strdup(keymap->ctx, led->name);
             free(led);
         }
     }
diff --git a/src/xkbcomp/keycodes.c b/src/xkbcomp/keycodes.c
index b6c9f59..145ea22 100644
--- a/src/xkbcomp/keycodes.c
+++ b/src/xkbcomp/keycodes.c
@@ -732,6 +732,7 @@ bool
 CompileKeycodes(XkbFile *file, struct xkb_keymap *keymap,
                 enum merge_mode merge)
 {
+    xkb_keycode_t i;
     KeyNamesInfo info; /* contains all the info after parsing */
 
     InitKeyNamesInfo(&info, file->id);
@@ -753,26 +754,20 @@ CompileKeycodes(XkbFile *file, struct xkb_keymap *keymap,
     else
         keymap->max_key_code = info.computedMax;
 
-    if (XkbcAllocNames(keymap, XkbKeyNamesMask | XkbIndicatorNamesMask, 0)
-        == Success) {
-        uint64_t i;
-        for (i = info.computedMin; i <= info.computedMax; i++)
-            LongToKeyName(darray_item(info.names, i),
-                          darray_item(keymap->names->keys, i).name);
-        if (info.name)
-            keymap->names->keycodes = strdup(info.name);
-    }
-    else {
-        WSGO("Cannot create struct xkb_names in CompileKeycodes\n");
-        goto err_info;
-    }
+    darray_resize0(keymap->key_names, keymap->max_key_code + 1);
+    for (i = info.computedMin; i <= info.computedMax; i++)
+        LongToKeyName(darray_item(info.names, i),
+                      darray_item(keymap->key_names, i).name);
+
+    if (info.name)
+        keymap->keycodes_section_name = strdup(info.name);
 
     if (info.leds) {
         IndicatorNameInfo *ii;
 
         for (ii = info.leds; ii; ii = (IndicatorNameInfo *) ii->defs.next) {
-            free(keymap->names->indicators[ii->ndx - 1]);
-            keymap->names->indicators[ii->ndx - 1] =
+            free(keymap->indicator_names[ii->ndx - 1]);
+            keymap->indicator_names[ii->ndx - 1] =
                 xkb_atom_strdup(keymap->ctx, ii->name);
         }
     }
diff --git a/src/xkbcomp/keytypes.c b/src/xkbcomp/keytypes.c
index 7a0874b..5036da7 100644
--- a/src/xkbcomp/keytypes.c
+++ b/src/xkbcomp/keytypes.c
@@ -1152,11 +1152,8 @@ CompileKeyTypes(XkbFile *file, struct xkb_keymap *keymap,
     if (info.errorCount != 0)
         goto err_info;
 
-    if (info.name) {
-        if (XkbcAllocNames(keymap, 0, 0) != Success)
-            goto err_info;
-        keymap->names->keytypes = strdup(info.name);
-    }
+    if (info.name)
+        keymap->types_section_name = strdup(info.name);
 
     i = info.nTypes;
     if ((info.stdPresent & XkbOneLevelMask) == 0)
diff --git a/src/xkbcomp/misc.c b/src/xkbcomp/misc.c
index bc65623..7692e8c 100644
--- a/src/xkbcomp/misc.c
+++ b/src/xkbcomp/misc.c
@@ -219,18 +219,17 @@ FindNamedKey(struct xkb_keymap *keymap, unsigned long name,
 {
     unsigned n;
 
-    if (start_from < keymap->min_key_code) {
+    if (start_from < keymap->min_key_code)
         start_from = keymap->min_key_code;
-    }
-    else if (start_from > keymap->max_key_code) {
+    else if (start_from > keymap->max_key_code)
         return false;
-    }
 
     *kc_rtrn = 0;               /* some callers rely on this */
-    if (keymap && keymap->names && !darray_empty(keymap->names->keys)) {
+
+    if (!darray_empty(keymap->key_names)) {
         for (n = start_from; n <= keymap->max_key_code; n++) {
             unsigned long tmp;
-            tmp = KeyNameToLong(darray_item(keymap->names->keys, n).name);
+            tmp = KeyNameToLong(darray_item(keymap->key_names, n).name);
             if (tmp == name) {
                 *kc_rtrn = n;
                 return true;
@@ -243,23 +242,16 @@ FindNamedKey(struct xkb_keymap *keymap, unsigned long name,
                                     create, 0);
         }
     }
+
     if (create) {
-        if ((!keymap->names) || darray_empty(keymap->names->keys)) {
-            if (XkbcAllocNames(keymap, XkbKeyNamesMask, 0) != Success) {
-                if (warningLevel > 0) {
-                    WARN("Couldn't allocate key names in FindNamedKey\n");
-                    ACTION("Key \"%s\" not automatically created\n",
-                           longText(name));
-                }
-                return false;
-            }
-        }
+        darray_resize0(keymap->key_names, keymap->max_key_code + 1);
+
         /* Find first unused keycode and store our key here */
         for (n = keymap->min_key_code; n <= keymap->max_key_code; n++) {
-            if (darray_item(keymap->names->keys, n).name[0] == '\0') {
+            if (darray_item(keymap->key_names, n).name[0] == '\0') {
                 char buf[XkbKeyNameLength + 1];
                 LongToKeyName(name, buf);
-                memcpy(darray_item(keymap->names->keys, n).name, buf,
+                memcpy(darray_item(keymap->key_names, n).name, buf,
                        XkbKeyNameLength);
                 *kc_rtrn = n;
                 return true;
@@ -276,15 +268,14 @@ FindKeyNameForAlias(struct xkb_keymap *keymap, unsigned long lname,
     char name[XkbKeyNameLength + 1];
     struct xkb_key_alias *a;
 
-    if (keymap && keymap->names) {
-        LongToKeyName(lname, name);
-        name[XkbKeyNameLength] = '\0';
-        darray_foreach(a, keymap->names->key_aliases) {
-            if (strncmp(name, a->alias, XkbKeyNameLength) == 0) {
-                *real_name = KeyNameToLong(a->real);
-                return true;
-            }
+    LongToKeyName(lname, name);
+    name[XkbKeyNameLength] = '\0';
+    darray_foreach(a, keymap->key_aliases) {
+        if (strncmp(name, a->alias, XkbKeyNameLength) == 0) {
+            *real_name = KeyNameToLong(a->real);
+            return true;
         }
     }
+
     return false;
 }
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index 2ae0ebe..7f8b9d1 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -1917,13 +1917,6 @@ CompileSymbols(XkbFile *file, struct xkb_keymap *keymap,
     if (info.errorCount != 0)
         goto err_info;
 
-    /* alloc memory in the xkb struct */
-    if (XkbcAllocNames(keymap, XkbGroupNamesMask, 0) != Success) {
-        WSGO("Can not allocate names in CompileSymbols\n");
-        ACTION("Symbols not added\n");
-        goto err_info;
-    }
-
     darray_resize0(keymap->key_sym_map, keymap->max_key_code + 1);
     keymap->modmap = calloc(keymap->max_key_code + 1,
                             sizeof(*keymap->modmap));
@@ -1956,16 +1949,16 @@ CompileSymbols(XkbFile *file, struct xkb_keymap *keymap,
     }
 
     if (info.name)
-        keymap->names->symbols = strdup(info.name);
+        keymap->symbols_section_name = strdup(info.name);
 
     /* now copy info into xkb. */
     ApplyAliases(keymap, &info.aliases);
 
     for (i = 0; i < XkbNumKbdGroups; i++) {
         if (info.groupNames[i] != XKB_ATOM_NONE) {
-            free(keymap->names->groups[i]);
-            keymap->names->groups[i] = xkb_atom_strdup(keymap->ctx,
-                                                       info.groupNames[i]);
+            free(keymap->group_names[i]);
+            keymap->group_names[i] = xkb_atom_strdup(keymap->ctx,
+                                                     info.groupNames[i]);
         }
     }
 
@@ -1980,12 +1973,12 @@ CompileSymbols(XkbFile *file, struct xkb_keymap *keymap,
 
     if (warningLevel > 3) {
         for (i = keymap->min_key_code; i <= keymap->max_key_code; i++) {
-            if (darray_item(keymap->names->keys, i).name[0] == '\0')
+            if (darray_item(keymap->key_names, i).name[0] == '\0')
                 continue;
 
             if (XkbKeyNumGroups(keymap, i) < 1) {
                 char buf[5];
-                memcpy(buf, darray_item(keymap->names->keys, i).name, 4);
+                memcpy(buf, darray_item(keymap->key_names, i).name, 4);
                 buf[4] = '\0';
                 WARN("No symbols defined for <%s> (keycode %d)\n", buf, i);
             }
diff --git a/src/xkbcomp/vmod.c b/src/xkbcomp/vmod.c
index 341f6be..4d200ec 100644
--- a/src/xkbcomp/vmod.c
+++ b/src/xkbcomp/vmod.c
@@ -36,24 +36,17 @@ InitVModInfo(VModInfo *info, struct xkb_keymap *keymap)
 void
 ClearVModInfo(VModInfo *info, struct xkb_keymap *keymap)
 {
-    int i;
+    int i, bit;
 
     info->newlyDefined = info->defined = info->available = 0;
 
-    if (XkbcAllocNames(keymap, 0, 0) != Success)
-        return;
-
     for (i = 0; i < XkbNumVirtualMods; i++)
         keymap->vmods[i] = XkbNoModifierMask;
 
     info->keymap = keymap;
-    if (keymap && keymap->names) {
-        int bit;
-        for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1) {
-            if (keymap->names->vmods[i] != NULL)
-                info->defined |= bit;
-        }
-    }
+    for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1)
+        if (keymap->vmod_names[i])
+            info->defined |= bit;
 }
 
 /***====================================================================***/
@@ -73,13 +66,12 @@ HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap,
 {
     int i, bit, nextFree;
     ExprResult mod;
-    struct xkb_names *names = keymap->names;
 
     for (i = 0, bit = 1, nextFree = -1; i < XkbNumVirtualMods; i++, bit <<=
              1) {
         if (info->defined & bit) {
-            if (names->vmods[i] &&
-                strcmp(names->vmods[i],
+            if (keymap->vmod_names[i] &&
+                strcmp(keymap->vmod_names[i],
                        xkb_atom_text(keymap->ctx, stmt->name)) == 0) { /* already defined */
                 info->available |= bit;
                 if (stmt->value == NULL)
@@ -121,7 +113,7 @@ HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap,
     info->defined |= (1 << nextFree);
     info->newlyDefined |= (1 << nextFree);
     info->available |= (1 << nextFree);
-    names->vmods[nextFree] = xkb_atom_strdup(keymap->ctx, stmt->name);
+    keymap->vmod_names[nextFree] = xkb_atom_strdup(keymap->ctx, stmt->name);
     if (stmt->value == NULL)
         return true;
     if (ExprResolveModMask(keymap->ctx, stmt->value, &mod)) {
@@ -134,7 +126,7 @@ HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap,
 }
 
 /**
- * Returns the index of the given modifier in the keymap->names->vmods array.
+ * Returns the index of the given modifier in the keymap->vmod_names array.
  *
  * @param keymap Pointer to the xkb data structure.
  * @param field The Atom of the modifier's name (e.g. Atom for LAlt)
@@ -151,21 +143,21 @@ LookupVModIndex(const struct xkb_keymap *keymap, xkb_atom_t field,
     int i;
     const char *name = xkb_atom_text(keymap->ctx, field);
 
-    if ((keymap == NULL) || (keymap->names == NULL) || (type != TypeInt)) {
+    if (type != TypeInt)
         return false;
-    }
+
     /* For each named modifier, get the name and compare it to the one passed
      * in. If we get a match, return the index of the modifier.
      * The order of modifiers is the same as in the virtual_modifiers line in
      * the xkb_types section.
      */
-    for (i = 0; i < XkbNumVirtualMods; i++) {
-        if (keymap->names->vmods[i] &&
-            strcmp(keymap->names->vmods[i], name) == 0) {
+    for (i = 0; i < XkbNumVirtualMods; i++)
+        if (keymap->vmod_names[i] &&
+            strcmp(keymap->vmod_names[i], name) == 0) {
             val_rtrn->uval = i;
             return true;
         }
-    }
+
     return false;
 }
 
@@ -211,14 +203,12 @@ bool
 ResolveVirtualModifier(ExprDef *def, struct xkb_keymap *keymap,
                        ExprResult *val_rtrn, VModInfo *info)
 {
-    struct xkb_names *names = keymap->names;
-
     if (def->op == ExprIdent) {
         int i, bit;
         const char *name = xkb_atom_text(keymap->ctx, def->value.str);
         for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1) {
-            if ((info->available & bit) && names->vmods[i] &&
-                strcmp(names->vmods[i], name) == 0) {
+            if ((info->available & bit) && keymap->vmod_names[i] &&
+                strcmp(keymap->vmod_names[i], name) == 0) {
                 val_rtrn->uval = i;
                 return true;
             }