Remove the Must_have_memory hack.
Also remove an astonishing amount of misunderstanding of how casts work.
This commit is contained in:
parent
e6b1c1fada
commit
0ce61e21d6
25
dix/events.c
25
dix/events.c
|
@ -2640,11 +2640,8 @@ XYToWindow(DeviceIntPtr pDev, int x, int y)
|
|||
if (pSprite->spriteTraceGood >= pSprite->spriteTraceSize)
|
||||
{
|
||||
pSprite->spriteTraceSize += 10;
|
||||
Must_have_memory = TRUE; /* XXX */
|
||||
pSprite->spriteTrace = (WindowPtr *)xrealloc(
|
||||
pSprite->spriteTrace,
|
||||
pSprite->spriteTrace = xrealloc(pSprite->spriteTrace,
|
||||
pSprite->spriteTraceSize*sizeof(WindowPtr));
|
||||
Must_have_memory = FALSE; /* XXX */
|
||||
}
|
||||
pSprite->spriteTrace[pSprite->spriteTraceGood++] = pWin;
|
||||
pWin = pWin->firstChild;
|
||||
|
@ -3462,11 +3459,8 @@ CheckPassiveGrabsOnWindow(
|
|||
{
|
||||
if (grabinfo->sync.evcount < scount)
|
||||
{
|
||||
Must_have_memory = TRUE; /* XXX */
|
||||
grabinfo->sync.event = (xEvent *)xrealloc(grabinfo->sync.event,
|
||||
scount*
|
||||
sizeof(xEvent));
|
||||
Must_have_memory = FALSE; /* XXX */
|
||||
grabinfo->sync.event = xrealloc(grabinfo->sync.event,
|
||||
scount * sizeof(xEvent));
|
||||
}
|
||||
grabinfo->sync.evcount = scount;
|
||||
/* we always store the XI event, never the core event */
|
||||
|
@ -3792,10 +3786,8 @@ DeliverGrabbedEvent(xEvent *xE, DeviceIntPtr thisDev,
|
|||
FreezeThaw(thisDev, TRUE);
|
||||
if (grabinfo->sync.evcount < count)
|
||||
{
|
||||
Must_have_memory = TRUE; /* XXX */
|
||||
grabinfo->sync.event = (xEvent *)xrealloc(grabinfo->sync.event,
|
||||
count*sizeof(xEvent));
|
||||
Must_have_memory = FALSE; /* XXX */
|
||||
grabinfo->sync.event = xrealloc(grabinfo->sync.event,
|
||||
count * sizeof(xEvent));
|
||||
}
|
||||
grabinfo->sync.evcount = count;
|
||||
for (dxE = grabinfo->sync.event; --count >= 0; dxE++, xE++)
|
||||
|
@ -4953,11 +4945,8 @@ SetInputFocus(
|
|||
if (depth > focus->traceSize)
|
||||
{
|
||||
focus->traceSize = depth+1;
|
||||
Must_have_memory = TRUE; /* XXX */
|
||||
focus->trace = (WindowPtr *)xrealloc(focus->trace,
|
||||
focus->traceSize *
|
||||
sizeof(WindowPtr));
|
||||
Must_have_memory = FALSE; /* XXX */
|
||||
focus->trace = xrealloc(focus->trace,
|
||||
focus->traceSize * sizeof(WindowPtr));
|
||||
}
|
||||
focus->traceGood = depth;
|
||||
for (pWin = focusWin, depth--; pWin; pWin = pWin->parent, depth--)
|
||||
|
|
|
@ -333,7 +333,6 @@ _X_HIDDEN void *dixLookupTab[] = {
|
|||
/* utils.c */
|
||||
SYMFUNC(Xstrdup)
|
||||
SYMFUNC(XNFstrdup)
|
||||
SYMVAR(Must_have_memory)
|
||||
SYMFUNC(AdjustWaitForDelay)
|
||||
SYMVAR(noTestExtensions)
|
||||
SYMFUNC(GiveUp)
|
||||
|
|
|
@ -19,7 +19,6 @@ extern char *defaultFontPath;
|
|||
extern int monitorResolution;
|
||||
extern int defaultColorVisualClass;
|
||||
|
||||
extern Bool Must_have_memory;
|
||||
extern WindowPtr WindowTable[MAXSCREENS];
|
||||
extern int GrabInProgress;
|
||||
extern Bool noTestExtensions;
|
||||
|
|
|
@ -54,8 +54,6 @@ SOFTWARE.
|
|||
#include "mi.h"
|
||||
#include "inputstr.h"
|
||||
|
||||
extern Bool Must_have_memory;
|
||||
|
||||
_X_EXPORT void
|
||||
miRecolorCursor(DeviceIntPtr pDev, ScreenPtr pScr,
|
||||
CursorPtr pCurs, Bool displayed)
|
||||
|
@ -64,11 +62,8 @@ miRecolorCursor(DeviceIntPtr pDev, ScreenPtr pScr,
|
|||
* This is guaranteed to correct any color-dependent state which may have
|
||||
* been bound up in private state created by RealizeCursor
|
||||
*/
|
||||
(* pScr->UnrealizeCursor)( pDev, pScr, pCurs);
|
||||
Must_have_memory = TRUE; /* XXX */
|
||||
(* pScr->RealizeCursor)( pDev, pScr, pCurs);
|
||||
Must_have_memory = FALSE; /* XXX */
|
||||
if ( displayed)
|
||||
(* pScr->DisplayCursor)( pDev, pScr, pCurs);
|
||||
|
||||
pScr->UnrealizeCursor(pDev, pScr, pCurs);
|
||||
pScr->RealizeCursor(pDev, pScr, pCurs);
|
||||
if (displayed)
|
||||
pScr->DisplayCursor(pDev, pScr, pCurs);
|
||||
}
|
||||
|
|
|
@ -63,11 +63,9 @@ miCreateGCOps(GCOpsPtr prototype)
|
|||
{
|
||||
GCOpsPtr ret;
|
||||
|
||||
/* XXX */ Must_have_memory = TRUE;
|
||||
ret = (GCOpsPtr) xalloc(sizeof(GCOps));
|
||||
/* XXX */ Must_have_memory = FALSE;
|
||||
ret = xalloc(sizeof(GCOps));
|
||||
if (!ret)
|
||||
return 0;
|
||||
return NULL;
|
||||
*ret = *prototype;
|
||||
ret->devPrivate.val = 1;
|
||||
return ret;
|
||||
|
|
74
os/utils.c
74
os/utils.c
|
@ -212,9 +212,6 @@ Bool PanoramiXExtensionDisabledHack = FALSE;
|
|||
|
||||
int auditTrailLevel = 1;
|
||||
|
||||
_X_EXPORT Bool Must_have_memory = FALSE;
|
||||
|
||||
|
||||
#if defined(SVR4) || defined(__linux__) || defined(CSRG_BASED)
|
||||
#define HAS_SAVED_IDS_AND_SETEUID
|
||||
#endif
|
||||
|
@ -1056,60 +1053,40 @@ set_font_authorizations(char **authorizations, int *authlen, pointer client)
|
|||
#endif /* TCPCONN */
|
||||
}
|
||||
|
||||
/* XALLOC -- X's internal memory allocator. Why does it return unsigned
|
||||
* long * instead of the more common char *? Well, if you read K&R you'll
|
||||
* see they say that alloc must return a pointer "suitable for conversion"
|
||||
* to whatever type you really want. In a full-blown generic allocator
|
||||
* there's no way to solve the alignment problems without potentially
|
||||
* wasting lots of space. But we have a more limited problem. We know
|
||||
* we're only ever returning pointers to structures which will have to
|
||||
* be long word aligned. So we are making a stronger guarantee. It might
|
||||
* have made sense to make Xalloc return char * to conform with people's
|
||||
* expectations of malloc, but this makes lint happier.
|
||||
*/
|
||||
|
||||
#ifndef INTERNAL_MALLOC
|
||||
|
||||
_X_EXPORT void *
|
||||
Xalloc(unsigned long amount)
|
||||
{
|
||||
register pointer ptr;
|
||||
void *ptr;
|
||||
|
||||
if ((long)amount <= 0) {
|
||||
return (unsigned long *)NULL;
|
||||
return NULL;
|
||||
}
|
||||
/* aligned extra on long word boundary */
|
||||
amount = (amount + (sizeof(long) - 1)) & ~(sizeof(long) - 1);
|
||||
if ((ptr = (pointer)malloc(amount))) {
|
||||
return (unsigned long *)ptr;
|
||||
}
|
||||
if (Must_have_memory)
|
||||
FatalError("Out of memory");
|
||||
return (unsigned long *)NULL;
|
||||
ptr = malloc(amount);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
/*****************
|
||||
* XNFalloc
|
||||
* "no failure" realloc, alternate interface to Xalloc w/o Must_have_memory
|
||||
* "no failure" realloc
|
||||
*****************/
|
||||
|
||||
_X_EXPORT void *
|
||||
XNFalloc(unsigned long amount)
|
||||
{
|
||||
register pointer ptr;
|
||||
void *ptr;
|
||||
|
||||
if ((long)amount <= 0)
|
||||
{
|
||||
return (unsigned long *)NULL;
|
||||
}
|
||||
return NULL;
|
||||
/* aligned extra on long word boundary */
|
||||
amount = (amount + (sizeof(long) - 1)) & ~(sizeof(long) - 1);
|
||||
ptr = (pointer)malloc(amount);
|
||||
ptr = malloc(amount);
|
||||
if (!ptr)
|
||||
{
|
||||
FatalError("Out of memory");
|
||||
}
|
||||
return ((unsigned long *)ptr);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
/*****************
|
||||
|
@ -1119,11 +1096,11 @@ XNFalloc(unsigned long amount)
|
|||
_X_EXPORT void *
|
||||
Xcalloc(unsigned long amount)
|
||||
{
|
||||
unsigned long *ret;
|
||||
void *ret;
|
||||
|
||||
ret = Xalloc (amount);
|
||||
if (ret)
|
||||
bzero ((char *) ret, (int) amount);
|
||||
bzero (ret, (int) amount);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1134,11 +1111,11 @@ Xcalloc(unsigned long amount)
|
|||
_X_EXPORT void *
|
||||
XNFcalloc(unsigned long amount)
|
||||
{
|
||||
unsigned long *ret;
|
||||
void *ret;
|
||||
|
||||
ret = Xalloc (amount);
|
||||
if (ret)
|
||||
bzero ((char *) ret, (int) amount);
|
||||
bzero (ret, (int) amount);
|
||||
else if ((long)amount > 0)
|
||||
FatalError("Out of memory");
|
||||
return ret;
|
||||
|
@ -1155,34 +1132,31 @@ Xrealloc(pointer ptr, unsigned long amount)
|
|||
{
|
||||
if (ptr && !amount)
|
||||
free(ptr);
|
||||
return (unsigned long *)NULL;
|
||||
return NULL;
|
||||
}
|
||||
amount = (amount + (sizeof(long) - 1)) & ~(sizeof(long) - 1);
|
||||
if (ptr)
|
||||
ptr = (pointer)realloc((char *)ptr, amount);
|
||||
ptr = realloc(ptr, amount);
|
||||
else
|
||||
ptr = (pointer)malloc(amount);
|
||||
if (ptr)
|
||||
return (unsigned long *)ptr;
|
||||
if (Must_have_memory)
|
||||
FatalError("Out of memory");
|
||||
return (unsigned long *)NULL;
|
||||
ptr = malloc(amount);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
/*****************
|
||||
* XNFrealloc
|
||||
* "no failure" realloc, alternate interface to Xrealloc w/o Must_have_memory
|
||||
* "no failure" realloc
|
||||
*****************/
|
||||
|
||||
_X_EXPORT void *
|
||||
XNFrealloc(pointer ptr, unsigned long amount)
|
||||
{
|
||||
if (( ptr = (pointer)Xrealloc( ptr, amount ) ) == NULL)
|
||||
if ((ptr = Xrealloc(ptr, amount)) == NULL)
|
||||
{
|
||||
if ((long)amount > 0)
|
||||
FatalError( "Out of memory" );
|
||||
}
|
||||
return ((unsigned long *)ptr);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
/*****************
|
||||
|
@ -1194,7 +1168,7 @@ _X_EXPORT void
|
|||
Xfree(pointer ptr)
|
||||
{
|
||||
if (ptr)
|
||||
free((char *)ptr);
|
||||
free(ptr);
|
||||
}
|
||||
#endif /* !INTERNAL_MALLOC */
|
||||
|
||||
|
@ -1207,7 +1181,7 @@ Xstrdup(const char *s)
|
|||
if (s == NULL)
|
||||
return NULL;
|
||||
|
||||
sd = (char *)Xalloc(strlen(s) + 1);
|
||||
sd = Xalloc(strlen(s) + 1);
|
||||
if (sd != NULL)
|
||||
strcpy(sd, s);
|
||||
return sd;
|
||||
|
@ -1222,7 +1196,7 @@ XNFstrdup(const char *s)
|
|||
if (s == NULL)
|
||||
return NULL;
|
||||
|
||||
sd = (char *)XNFalloc(strlen(s) + 1);
|
||||
sd = XNFalloc(strlen(s) + 1);
|
||||
strcpy(sd, s);
|
||||
return sd;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue