From d95b289367c4c6cd95042db35c88a6deb20c925b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristian=20H=C3=B8gsberg?= Date: Wed, 30 Jun 2010 17:13:21 -0400 Subject: [PATCH] Make XkbcInitAtoms() call optional --- src/atom.c | 19 +++++++++---------- test/filecomp.c | 1 - test/namescomp.c | 1 - test/rulescomp.c | 1 - 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/atom.c b/src/atom.c index f50b9e7..baab640 100644 --- a/src/atom.c +++ b/src/atom.c @@ -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; } diff --git a/test/filecomp.c b/test/filecomp.c index dc20681..cd824c0 100644 --- a/test/filecomp.c +++ b/test/filecomp.c @@ -60,7 +60,6 @@ int main(int argc, char *argv[]) } uSetErrorFile(NULL); - XkbcInitAtoms(NULL, NULL); xkb = XkbcCompileKeymapFromFile(file, name); fclose(file); diff --git a/test/namescomp.c b/test/namescomp.c index 3c34d0c..f1ea4b5 100644 --- a/test/namescomp.c +++ b/test/namescomp.c @@ -54,7 +54,6 @@ int main(int argc, char *argv[]) ktcsg.geometry = argv[5]; uSetErrorFile(NULL); - XkbcInitAtoms(NULL, NULL); xkb = XkbcCompileKeymapFromComponents(&ktcsg); diff --git a/test/rulescomp.c b/test/rulescomp.c index 102c3e9..6368ab6 100644 --- a/test/rulescomp.c +++ b/test/rulescomp.c @@ -53,7 +53,6 @@ int main(int argc, char *argv[]) rmlvo.options = argv[5]; uSetErrorFile(NULL); - XkbcInitAtoms(NULL, NULL); xkb = XkbcCompileKeymapFromRules(&rmlvo); -- 2.7.4