Make XkbcInitAtoms() call optional
authorKristian Høgsberg <krh@bitplanet.net>
Wed, 30 Jun 2010 21:13:21 +0000 (17:13 -0400)
committerKristian Høgsberg <krh@bitplanet.net>
Wed, 30 Jun 2010 21:13:21 +0000 (17:13 -0400)
src/atom.c
test/filecomp.c
test/namescomp.c
test/rulescomp.c

index f50b9e7c35f7b82ba207f097e05947e71e8e7dfa..baab640b85d4188f1dacc7e4abea4863c4a6ab9d 100644 (file)
@@ -105,13 +105,6 @@ XkbcInitAtoms(InternAtomFuncPtr intern, GetAtomValueFuncPtr get_atom_value)
         do_get_atom_value = get_atom_value;
         return;
     }
-
-    if (nodeTable)
-        return;
-
-    tableLength = InitialTableSize;
-    nodeTable = (NodePtr *)malloc(InitialTableSize * sizeof(NodePtr));
-    nodeTable[None] = NULL;
 }
 
 static const char *
@@ -202,16 +195,22 @@ _XkbcMakeAtom(const char *string, unsigned len, Bool makeit)
 
         if ((lastAtom + 1) >= tableLength) {
             NodePtr *table;
+           int newLength;
+
+           if (tableLength == 0)
+               newLength = InitialTableSize;
+           else
+               newLength = tableLength * 2;
 
-            table = (NodePtr *)realloc(nodeTable,
-                                           tableLength * 2 * sizeof(NodePtr));
+            table = realloc(nodeTable, newLength * sizeof(NodePtr));
             if (!table) {
                 if (nd->string != string)
                     free(nd->string);
                 free(nd);
                 return BAD_RESOURCE;
             }
-            tableLength <<= 1;
+            tableLength = newLength;
+           table[None] = NULL;
 
             nodeTable = table;
         }
index dc2068151ec4d2b0c61f2fb700990e8c9ef2cdf3..cd824c08688d96f9e6e91a5b69f3c5661218aadd 100644 (file)
@@ -60,7 +60,6 @@ int main(int argc, char *argv[])
     }
 
     uSetErrorFile(NULL);
-    XkbcInitAtoms(NULL, NULL);
 
     xkb = XkbcCompileKeymapFromFile(file, name);
     fclose(file);
index 3c34d0c863b88a3c05e73dd44882c97e27772e9c..f1ea4b5f841406720226a5d138d204281f7d18ba 100644 (file)
@@ -54,7 +54,6 @@ int main(int argc, char *argv[])
     ktcsg.geometry = argv[5];
 
     uSetErrorFile(NULL);
-    XkbcInitAtoms(NULL, NULL);
 
     xkb = XkbcCompileKeymapFromComponents(&ktcsg);
 
index 102c3e96d86ef07199c74d6e7f25086602268f95..6368ab65043a3c6fcbc8f66eec4297a8aa66d577 100644 (file)
@@ -53,7 +53,6 @@ int main(int argc, char *argv[])
     rmlvo.options = argv[5];
 
     uSetErrorFile(NULL);
-    XkbcInitAtoms(NULL, NULL);
 
     xkb = XkbcCompileKeymapFromRules(&rmlvo);