aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/dix/atom.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-03-23 10:05:55 +0100
committermarha <marha@users.sourceforge.net>2012-03-23 10:05:55 +0100
commit0f834b91a4768673833ab4917e87d86c237bb1a6 (patch)
tree363489504ed4b2d360259b8de4c9e392918e5d02 /xorg-server/dix/atom.c
parentfc72edebf875378459368c5383d9023730cbca54 (diff)
downloadvcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.tar.gz
vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.tar.bz2
vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.zip
libX11 xserver fontconfig mesa pixman xkbcomp xkeyboard-config git update
23 Mar 2012
Diffstat (limited to 'xorg-server/dix/atom.c')
-rw-r--r--xorg-server/dix/atom.c143
1 files changed, 69 insertions, 74 deletions
diff --git a/xorg-server/dix/atom.c b/xorg-server/dix/atom.c
index 83ff71a7d..6f85968cd 100644
--- a/xorg-server/dix/atom.c
+++ b/xorg-server/dix/atom.c
@@ -22,7 +22,6 @@ Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
-
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
All Rights Reserved
@@ -45,7 +44,6 @@ SOFTWARE.
******************************************************************/
-
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
@@ -61,10 +59,10 @@ SOFTWARE.
#define InitialTableSize 100
typedef struct _Node {
- struct _Node *left, *right;
+ struct _Node *left, *right;
Atom a;
unsigned int fingerPrint;
- const char *string;
+ const char *string;
} NodeRec, *NodePtr;
static Atom lastAtom = None;
@@ -77,77 +75,71 @@ void FreeAtom(NodePtr patom);
Atom
MakeAtom(const char *string, unsigned len, Bool makeit)
{
- NodePtr * np;
+ NodePtr *np;
unsigned i;
int comp;
unsigned int fp = 0;
np = &atomRoot;
- for (i = 0; i < (len+1)/2; i++)
- {
- fp = fp * 27 + string[i];
- fp = fp * 27 + string[len - 1 - i];
+ for (i = 0; i < (len + 1) / 2; i++) {
+ fp = fp * 27 + string[i];
+ fp = fp * 27 + string[len - 1 - i];
}
- while (*np != NULL)
- {
- if (fp < (*np)->fingerPrint)
- np = &((*np)->left);
- else if (fp > (*np)->fingerPrint)
- np = &((*np)->right);
- else
- { /* now start testing the strings */
- comp = strncmp(string, (*np)->string, (int)len);
- if ((comp < 0) || ((comp == 0) && (len < strlen((*np)->string))))
- np = &((*np)->left);
- else if (comp > 0)
- np = &((*np)->right);
- else
- return(*np)->a;
- }
+ while (*np != NULL) {
+ if (fp < (*np)->fingerPrint)
+ np = &((*np)->left);
+ else if (fp > (*np)->fingerPrint)
+ np = &((*np)->right);
+ else { /* now start testing the strings */
+ comp = strncmp(string, (*np)->string, (int) len);
+ if ((comp < 0) || ((comp == 0) && (len < strlen((*np)->string))))
+ np = &((*np)->left);
+ else if (comp > 0)
+ np = &((*np)->right);
+ else
+ return (*np)->a;
+ }
}
- if (makeit)
- {
- NodePtr nd;
-
- nd = malloc(sizeof(NodeRec));
- if (!nd)
- return BAD_RESOURCE;
- if (lastAtom < XA_LAST_PREDEFINED)
- {
- nd->string = string;
- }
- else
- {
- nd->string = strndup(string, len);
- if (!nd->string) {
- free(nd);
- return BAD_RESOURCE;
- }
- }
- if ((lastAtom + 1) >= tableLength) {
- NodePtr *table;
-
- table = realloc(nodeTable, tableLength * (2 * sizeof(NodePtr)));
- if (!table) {
- if (nd->string != string) {
+ if (makeit) {
+ NodePtr nd;
+
+ nd = malloc(sizeof(NodeRec));
+ if (!nd)
+ return BAD_RESOURCE;
+ if (lastAtom < XA_LAST_PREDEFINED) {
+ nd->string = string;
+ }
+ else {
+ nd->string = strndup(string, len);
+ if (!nd->string) {
+ free(nd);
+ return BAD_RESOURCE;
+ }
+ }
+ if ((lastAtom + 1) >= tableLength) {
+ NodePtr *table;
+
+ table = realloc(nodeTable, tableLength * (2 * sizeof(NodePtr)));
+ if (!table) {
+ if (nd->string != string) {
/* nd->string has been strdup'ed */
- free((char *)nd->string);
+ free((char *) nd->string);
}
- free(nd);
- return BAD_RESOURCE;
- }
- tableLength <<= 1;
- nodeTable = table;
- }
- *np = nd;
- nd->left = nd->right = NULL;
- nd->fingerPrint = fp;
- nd->a = ++lastAtom;
- nodeTable[lastAtom] = nd;
- return nd->a;
+ free(nd);
+ return BAD_RESOURCE;
+ }
+ tableLength <<= 1;
+ nodeTable = table;
+ }
+ *np = nd;
+ nd->left = nd->right = NULL;
+ nd->fingerPrint = fp;
+ nd->a = ++lastAtom;
+ nodeTable[lastAtom] = nd;
+ return nd->a;
}
else
- return None;
+ return None;
}
Bool
@@ -160,8 +152,11 @@ const char *
NameForAtom(Atom atom)
{
NodePtr node;
- if (atom > lastAtom) return 0;
- if ((node = nodeTable[atom]) == NULL) return 0;
+
+ if (atom > lastAtom)
+ return 0;
+ if ((node = nodeTable[atom]) == NULL)
+ return 0;
return node->string;
}
@@ -174,16 +169,16 @@ AtomError(void)
void
FreeAtom(NodePtr patom)
{
- if(patom->left)
- FreeAtom(patom->left);
- if(patom->right)
- FreeAtom(patom->right);
+ if (patom->left)
+ FreeAtom(patom->left);
+ if (patom->right)
+ FreeAtom(patom->right);
if (patom->a > XA_LAST_PREDEFINED) {
/*
* All strings above XA_LAST_PREDEFINED are strdup'ed, so it's safe to
* cast here
*/
- free((char *)patom->string);
+ free((char *) patom->string);
}
free(patom);
}
@@ -192,7 +187,7 @@ void
FreeAllAtoms(void)
{
if (atomRoot == NULL)
- return;
+ return;
FreeAtom(atomRoot);
atomRoot = NULL;
free(nodeTable);
@@ -207,9 +202,9 @@ InitAtoms(void)
tableLength = InitialTableSize;
nodeTable = malloc(InitialTableSize * sizeof(NodePtr));
if (!nodeTable)
- AtomError();
+ AtomError();
nodeTable[None] = NULL;
MakePredeclaredAtoms();
if (lastAtom != XA_LAST_PREDEFINED)
- AtomError();
+ AtomError();
}