Commit 7e975e3c authored by Ulrich Sibiller's avatar Ulrich Sibiller

simply free() calls

free() can handle NULL so there's no need to check this ourselves
parent 3b640a0f
......@@ -729,12 +729,8 @@ int ddxProcessArgument(int argc, char *argv[], int i)
{
int size;
if (nxagentKeyboard != NULL)
{
free(nxagentKeyboard);
nxagentKeyboard = NULL;
}
free(nxagentKeyboard);
nxagentKeyboard = NULL;
if ((size = strlen(argv[i])) < 256)
{
......
......@@ -974,11 +974,8 @@ void nxagentNotifySelection(XEvent *X)
}
/*
* if (pszReturnData)
* {
* free(pszReturnData);
* pszReturnData=NULL;
* }
* free(pszReturnData);
* pszReturnData=NULL;
*/
}
......@@ -1500,11 +1497,8 @@ int nxagentInitClipboard(WindowPtr pWin)
fprintf(stderr, "nxagentInitClipboard: Got called.\n");
#endif
if (lastSelectionOwner != NULL)
{
free(lastSelectionOwner);
lastSelectionOwner = NULL;
}
free(lastSelectionOwner);
lastSelectionOwner = NULL;
lastSelectionOwner = (SelectionOwner *) malloc(2 * sizeof(SelectionOwner));
......
......@@ -257,8 +257,7 @@ void nxagentSetInstalledColormapWindows(ScreenPtr pScreen)
free(icws.cmapIDs);
if (!nxagentSameInstalledColormapWindows(icws.windows, icws.numWindows)) {
if (nxagentOldInstalledColormapWindows)
free(nxagentOldInstalledColormapWindows);
free(nxagentOldInstalledColormapWindows);
#ifdef _XSERVER64
{
......@@ -318,13 +317,12 @@ void nxagentSetInstalledColormapWindows(ScreenPtr pScreen)
#endif /* DUMB_WINDOW_MANAGERS */
}
else
if (icws.windows) free(icws.windows);
free(icws.windows);
}
void nxagentSetScreenSaverColormapWindow(ScreenPtr pScreen)
{
if (nxagentOldInstalledColormapWindows)
free(nxagentOldInstalledColormapWindows);
free(nxagentOldInstalledColormapWindows);
#ifdef _XSERVER64
{
......
......@@ -264,7 +264,7 @@ int nxagentSynchronizeDrawableData(DrawablePtr pDrawable, unsigned int breakMask
success = 0;
goto nxagentSynchronizeDrawableDataFree;
goto nxagentSynchronizeDrawableDataEnd;
}
ValidateGC(pDrawable, pGC);
......@@ -282,7 +282,7 @@ int nxagentSynchronizeDrawableData(DrawablePtr pDrawable, unsigned int breakMask
success = 1;
goto nxagentSynchronizeDrawableDataFree;
goto nxagentSynchronizeDrawableDataEnd;
}
else if (nxagentReconnectTrap == 1)
{
......@@ -323,7 +323,7 @@ int nxagentSynchronizeDrawableData(DrawablePtr pDrawable, unsigned int breakMask
success = 0;
goto nxagentSynchronizeDrawableDataFree;
goto nxagentSynchronizeDrawableDataEnd;
}
ValidateGC(pDrawable, pGC);
......@@ -336,7 +336,7 @@ int nxagentSynchronizeDrawableData(DrawablePtr pDrawable, unsigned int breakMask
success = 1;
goto nxagentSynchronizeDrawableDataFree;
goto nxagentSynchronizeDrawableDataEnd;
}
else
{
......@@ -349,7 +349,7 @@ int nxagentSynchronizeDrawableData(DrawablePtr pDrawable, unsigned int breakMask
success = 1;
goto nxagentSynchronizeDrawableDataFree;
goto nxagentSynchronizeDrawableDataEnd;
}
}
}
......@@ -363,14 +363,8 @@ int nxagentSynchronizeDrawableData(DrawablePtr pDrawable, unsigned int breakMask
success = nxagentSynchronizeRegion(pDrawable, NullRegion, breakMask, owner);
nxagentSynchronizeDrawableDataFree:
if (data != NULL)
{
free(data);
}
nxagentSynchronizeDrawableDataEnd:
free(data);
return success;
}
......@@ -866,10 +860,7 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned
#endif
}
if (cmpData != NULL)
{
free(cmpData);
}
free(cmpData);
}
}
else
......@@ -1066,10 +1057,7 @@ nxagentSynchronizeRegionFree:
nxagentFreeRegion(pDrawable, clipRegion);
}
if (data != NULL)
{
free(data);
}
free(data);
RegionUninit(&exposeRegion);
......
......@@ -841,10 +841,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP
for (j = 0; j < numSearchFields; j++)
{
if (searchFields[j] != NULL)
{
free(searchFields[j]);
}
free(searchFields[j]);
}
}
}
......@@ -863,10 +860,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP
for (j = 0; j < numFontFields; j++)
{
if (fontNameFields[j] != NULL)
{
free(fontNameFields[j]);
}
free(fontNameFields[j]);
}
return fontStruct;
......@@ -1260,17 +1254,11 @@ static void nxagentFailedFontReconnect(FontPtr pFont, XID param1, void * param2)
static void nxagentFreeFailedToReconnectFonts()
{
if (nxagentFailedToReconnectFonts.font != NULL)
{
free(nxagentFailedToReconnectFonts.font);
nxagentFailedToReconnectFonts.font = NULL;
}
free(nxagentFailedToReconnectFonts.font);
nxagentFailedToReconnectFonts.font = NULL;
if (nxagentFailedToReconnectFonts.id != NULL)
{
free(nxagentFailedToReconnectFonts.id);
nxagentFailedToReconnectFonts.id = NULL;
}
free(nxagentFailedToReconnectFonts.id);
nxagentFailedToReconnectFonts.id = NULL;
nxagentFailedToReconnectFonts.size = 0;
nxagentFailedToReconnectFonts.index = 0;
......@@ -1706,10 +1694,7 @@ int nxagentFreeFont(XFontStruct *fs)
#endif
}
if (fs -> properties)
{
free (fs->properties);
}
free (fs->properties);
XFree(fs);
......
......@@ -924,10 +924,7 @@ static void nxagentRestoreGCRec(struct nxagentGCRec *t)
(void*)t, (void*)t -> gc);
#endif
if (nxagentGC(t -> pGC))
{
free(nxagentGC(t -> pGC));
}
free(nxagentGC(t -> pGC));
nxagentGC(t -> pGC) = t -> gc;
......
......@@ -1545,10 +1545,7 @@ void nxagentFillPolygon(DrawablePtr pDrawable, GCPtr pGC, int shape,
RESET_GC_TRAP();
}
if (newPoints != NULL)
{
free(newPoints);
}
free(newPoints);
}
void nxagentPolyFillRect(DrawablePtr pDrawable, GCPtr pGC,
......
......@@ -1567,10 +1567,7 @@ nxagentPutSubImageEnd:
nxagentImageStatistics.totalEncoded, nxagentImageStatistics.totalAdded);
#endif
if (packedChecksum != NULL)
{
free(packedChecksum);
}
free(packedChecksum);
if (packedImage != NULL)
{
......@@ -1787,11 +1784,7 @@ int nxagentScaleImage(int x, int y, unsigned xRatio, unsigned yRatio,
}
}
if (image -> obdata != NULL)
{
free((char *) image -> obdata);
}
free((char *) image -> obdata);
free((char *) image);
*pImage = newImage;
......
......@@ -1172,10 +1172,7 @@ Bool nxagentCheckPixmapIntegrity(PixmapPtr pPixmap)
XDestroyImage(image);
}
if (data != NULL)
{
free(data);
}
free(data);
}
else
{
......@@ -1421,10 +1418,7 @@ FIXME: If the pixmap has a different depth from the window, the
fprintf(stderr, "nxagentPixmapOnShadowDisplay: XCreateImage failed.\n");
#endif
if (data != NULL)
{
free(data);
}
free(data);
return False;
}
......@@ -1583,10 +1577,7 @@ Bool nxagentFbOnShadowDisplay()
fprintf(stderr, "nxagentFbOnShadowDisplay: XCreateImage failed.\n");
#endif
if (data)
{
free(data);
}
free(data);
return False;
}
......
......@@ -610,12 +610,8 @@ Bool nxagentReconnectSession(void)
nxagentXkbState.Initialized = 0;
if (nxagentOldKeyboard != NULL)
{
free(nxagentOldKeyboard);
nxagentOldKeyboard = NULL;
}
free(nxagentOldKeyboard);
nxagentOldKeyboard = NULL;
nxagentInitPointerMap();
......@@ -739,12 +735,8 @@ nxagentReconnectError:
nxagentDisconnectDisplay();
}
if (nxagentOldKeyboard != NULL)
{
free(nxagentOldKeyboard);
nxagentOldKeyboard = NULL;
}
free(nxagentOldKeyboard);
nxagentOldKeyboard = NULL;
return 0;
}
......
......@@ -3079,10 +3079,7 @@ int nxagentShadowPoll(PixmapPtr nxagentShadowPixmapPtr, GCPtr nxagentShadowGCPtr
length = nxagentImageLength(width, height, ZPixmap, 0, nxagentMasterDepth);
if (tBuffer)
{
free(tBuffer);
}
free(tBuffer);
tBuffer = malloc(length);
......@@ -3139,10 +3136,7 @@ int nxagentShadowPoll(PixmapPtr nxagentShadowPixmapPtr, GCPtr nxagentShadowGCPtr
RegionUnion(&nxagentShadowUpdateRegion, &nxagentShadowUpdateRegion, &updateRegion);
}
if (tBuffer)
{
free(tBuffer);
}
free(tBuffer);
RegionUninit(&updateRegion);
}
......@@ -3360,10 +3354,7 @@ void nxagentShadowAdaptDepth(unsigned int width, unsigned int height,
cBuffer = (unsigned char *) *buffer;
*buffer = (char *) icBuffer;
if (cBuffer != NULL)
{
free(cBuffer);
}
free(cBuffer);
}
#ifdef NXAGENT_ARTSD
......@@ -3826,9 +3817,8 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen)
#endif
number = 1;
if (screeninfo) {
free(screeninfo);
}
free(screeninfo);
if (!(screeninfo = malloc(sizeof(XineramaScreenInfo)))) {
return FALSE;
}
......@@ -4111,10 +4101,8 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen)
}
/* release allocated memory */
if (screeninfo) {
free(screeninfo);
screeninfo = NULL;
}
free(screeninfo);
screeninfo = NULL;
#ifdef DEBUG
for (i = 0; i < pScrPriv->numCrtcs; i++) {
......@@ -4587,10 +4575,7 @@ FIXME
fprintf(stderr, "nxagentShowPixmap: XGetImage failed.\n");
#endif
if (data)
{
free(data);
}
free(data);
return;
}
......@@ -4623,10 +4608,7 @@ FIXME
XDestroyImage(image);
}
if (data != NULL)
{
free(data);
}
free(data);
/*
FIXME
......@@ -4678,10 +4660,7 @@ void nxagentFbRestoreArea(PixmapPtr pPixmap, WindowPtr pWin, int xSrc, int ySrc,
fprintf(stderr, "nxagentFbRestoreArea: XGetImage failed.\n");
#endif
if (data)
{
free(data);
}
free(data);
return;
}
......@@ -4741,10 +4720,7 @@ FIXME
/*
FIXME
if (data)
{
free(data);
}
free(data);
*/
}
......
......@@ -3151,12 +3151,7 @@ FIXME: Do we need to set save unders attribute here?
&hints);
#ifdef _XSERVER64
if (data64 != NULL)
{
free(data64);
}
free(data64);
#endif
}
}
......@@ -3404,10 +3399,7 @@ Bool nxagentCheckWindowIntegrity(WindowPtr pWin)
XDestroyImage(image);
}
if (data)
{
free(data);
}
free(data);
}
else
{
......@@ -3947,11 +3939,8 @@ int nxagentEmptyBSPixmapList()
for (i = 0; i < BSPIXMAPLIMIT; i++)
{
if (nxagentBSPixmapList[i] != NULL)
{
free(nxagentBSPixmapList[i]);
nxagentBSPixmapList[i] = NULL;
}
free(nxagentBSPixmapList[i]);
nxagentBSPixmapList[i] = NULL;
}
return 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment