[PATCH 3/4] Remove useless casts
Mikhail Gusarov
dottedmag at dottedmag.net
Wed May 12 13:56:36 PDT 2010
Signed-off-by: Mikhail Gusarov <dottedmag at dottedmag.net>
---
dix/atom.c | 25 +++++++++++++------------
1 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/dix/atom.c b/dix/atom.c
index 02843d2..7d04c68 100644
--- a/dix/atom.c
+++ b/dix/atom.c
@@ -68,7 +68,7 @@ typedef struct _Node {
} NodeRec, *NodePtr;
static Atom lastAtom = None;
-static NodePtr atomRoot = (NodePtr)NULL;
+static NodePtr atomRoot = NULL;
static unsigned long tableLength;
static NodePtr *nodeTable;
@@ -88,7 +88,7 @@ MakeAtom(const char *string, unsigned len, Bool makeit)
fp = fp * 27 + string[i];
fp = fp * 27 + string[len - 1 - i];
}
- while (*np != (NodePtr) NULL)
+ while (*np != NULL)
{
if (fp < (*np)->fingerPrint)
np = &((*np)->left);
@@ -130,11 +130,12 @@ MakeAtom(const char *string, unsigned len, Bool makeit)
if ((lastAtom + 1) >= tableLength) {
NodePtr *table;
- table = (NodePtr *) realloc(nodeTable,
- tableLength * (2 * sizeof(NodePtr)));
+ table = realloc(nodeTable, tableLength * (2 * sizeof(NodePtr)));
if (!table) {
- if (nd->string != string)
- free(nd->string);
+ if (nd->string != string) {
+ /* nd->string has been strdup'ed */
+ free((char *)nd->string);
+ }
free(nd);
return BAD_RESOURCE;
}
@@ -142,7 +143,7 @@ MakeAtom(const char *string, unsigned len, Bool makeit)
nodeTable = table;
}
*np = nd;
- nd->left = nd->right = (NodePtr) NULL;
+ nd->left = nd->right = NULL;
nd->fingerPrint = fp;
nd->a = (++lastAtom);
*(nodeTable+lastAtom) = nd;
@@ -163,7 +164,7 @@ NameForAtom(Atom atom)
{
NodePtr node;
if (atom > lastAtom) return 0;
- if ((node = nodeTable[atom]) == (NodePtr)NULL) return 0;
+ if ((node = nodeTable[atom]) == NULL) return 0;
return node->string;
}
@@ -193,12 +194,12 @@ FreeAtom(NodePtr patom)
void
FreeAllAtoms(void)
{
- if(atomRoot == (NodePtr)NULL)
+ if(atomRoot == NULL)
return;
FreeAtom(atomRoot);
- atomRoot = (NodePtr)NULL;
+ atomRoot = NULL;
free(nodeTable);
- nodeTable = (NodePtr *)NULL;
+ nodeTable = NULL;
lastAtom = None;
}
@@ -210,7 +211,7 @@ InitAtoms(void)
nodeTable = malloc(InitialTableSize*sizeof(NodePtr));
if (!nodeTable)
AtomError();
- nodeTable[None] = (NodePtr)NULL;
+ nodeTable[None] = NULL;
MakePredeclaredAtoms();
if (lastAtom != XA_LAST_PREDEFINED)
AtomError();
--
1.7.1
More information about the xorg-devel
mailing list