summaryrefslogtreecommitdiff
path: root/src/atom.c
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2010-06-30 17:13:21 -0400
committerKristian Høgsberg <krh@bitplanet.net>2010-06-30 17:13:21 -0400
commitd95b289367c4c6cd95042db35c88a6deb20c925b (patch)
tree7c8c7309f93f8a8a606aebab125c496c631d2f62 /src/atom.c
parent0ece2cdbaf776a16f8864a7314ad2089a4b9980f (diff)
downloadxorg-lib-libxkbcommon-d95b289367c4c6cd95042db35c88a6deb20c925b.tar.gz
Make XkbcInitAtoms() call optional
Diffstat (limited to 'src/atom.c')
-rw-r--r--src/atom.c19
1 files changed, 9 insertions, 10 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;
}