Merge remote branch 'dottedmag/for-keithp'

This commit is contained in:
Keith Packard 2010-05-12 16:48:08 -07:00
commit 59857ee5da
7 changed files with 40 additions and 35 deletions

View File

@ -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,10 +143,10 @@ 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;
nd->a = ++lastAtom;
nodeTable[lastAtom] = nd;
return nd->a;
}
else
@ -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;
}
@ -180,20 +181,25 @@ FreeAtom(NodePtr patom)
FreeAtom(patom->left);
if(patom->right)
FreeAtom(patom->right);
if (patom->a > XA_LAST_PREDEFINED)
free(patom->string);
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(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;
}
@ -202,11 +208,11 @@ InitAtoms(void)
{
FreeAllAtoms();
tableLength = InitialTableSize;
nodeTable = malloc(InitialTableSize*sizeof(NodePtr));
nodeTable = malloc(InitialTableSize * sizeof(NodePtr));
if (!nodeTable)
AtomError();
nodeTable[None] = (NodePtr)NULL;
nodeTable[None] = NULL;
MakePredeclaredAtoms();
if (lastAtom != XA_LAST_PREDEFINED)
AtomError ();
AtomError();
}

View File

@ -106,6 +106,12 @@ typedef unsigned long ATOM;
#define X_DEPRECATED
#endif
#if defined(__GNUC__) && (__GNUC__ > 2)
#define X_NORETURN __attribute__((noreturn))
#else
#define X_NORETURN
#endif
#ifndef _XTYPEDEF_CALLBACKLISTPTR
typedef struct _CallbackList *CallbackListPtr; /* also in dix.h */
#define _XTYPEDEF_CALLBACKLISTPTR

View File

@ -299,7 +299,7 @@ extern _X_EXPORT void OsBlockSignals (void);
extern _X_EXPORT void OsReleaseSignals (void);
extern _X_EXPORT void OsAbort (void);
extern _X_EXPORT void OsAbort (void) X_NORETURN;
#if !defined(WIN32)
extern _X_EXPORT int System(char *);
@ -547,10 +547,7 @@ extern _X_EXPORT void FreeAuditTimer(void);
extern _X_EXPORT void AuditF(const char *f, ...) _printf_attribute(1,2);
extern _X_EXPORT void VAuditF(const char *f, va_list args);
extern _X_EXPORT void FatalError(const char *f, ...) _printf_attribute(1,2)
#if defined(__GNUC__) && (__GNUC__ > 2)
__attribute((noreturn))
#endif
;
X_NORETURN;
#ifdef DEBUG
#define DebugF ErrorF

View File

@ -73,7 +73,7 @@ miPolyPoint(
int i;
xPoint *ppt;
if(!(pwidthInit = xalloc(npt * sizeof(int))))
if(!(pwidthInit = malloc(npt * sizeof(int))))
return;
/* make pointlist origin relative */

View File

@ -402,9 +402,8 @@ LogMessage(MessageType type, const char *format, ...)
va_end(ap);
}
#ifdef __GNUC__
void AbortServer(void) __attribute__((noreturn));
#endif
void
AbortServer(void) X_NORETURN;
void
AbortServer(void)

View File

@ -161,7 +161,6 @@ void
OsInit(void)
{
static Bool been_here = FALSE;
static char* admpath = ADMPATH;
static char* devnull = "/dev/null";
char fname[PATH_MAX];
@ -229,8 +228,8 @@ OsInit(void)
{
FILE *err;
if (strlen (display) + strlen (admpath) + 1 < sizeof fname)
sprintf (fname, admpath, display);
if (strlen (display) + strlen (ADMPATH) + 1 < sizeof fname)
sprintf (fname, ADMPATH, display);
else
strcpy (fname, devnull);
/*

View File

@ -186,7 +186,7 @@ XkbDDXCompileKeymapByNames( XkbDescPtr xkb,
char *buf = NULL, keymap[PATH_MAX], xkm_output_dir[PATH_MAX];
const char *emptystring = "";
const char *xkbbasedirflag = emptystring;
char *xkbbasedirflag = NULL;
const char *xkbbindir = emptystring;
const char *xkbbindirsep = emptystring;
@ -230,13 +230,11 @@ XkbDDXCompileKeymapByNames( XkbDescPtr xkb,
xkbbindir, xkbbindirsep,
( (xkbDebugFlags < 2) ? 1 :
((xkbDebugFlags > 10) ? 10 : (int)xkbDebugFlags) ),
xkbbasedirflag, xkmfile,
xkbbasedirflag ? xkbbasedirflag : "", xkmfile,
PRE_ERROR_MSG, ERROR_PREFIX, POST_ERROR_MSG1,
xkm_output_dir, keymap);
if (xkbbasedirflag != emptystring) {
free(xkbbasedirflag);
}
free(xkbbasedirflag);
#ifndef WIN32
out= Popen(buf,"w");