Unverified Commit ce182e88 authored by Mike Gabriel's avatar Mike Gabriel

Merge branch 'uli42-pr/simplify_free' into 3.6.x

parents 3b640a0f dc43f4c9
...@@ -729,12 +729,8 @@ int ddxProcessArgument(int argc, char *argv[], int i) ...@@ -729,12 +729,8 @@ int ddxProcessArgument(int argc, char *argv[], int i)
{ {
int size; int size;
if (nxagentKeyboard != NULL) free(nxagentKeyboard);
{ nxagentKeyboard = NULL;
free(nxagentKeyboard);
nxagentKeyboard = NULL;
}
if ((size = strlen(argv[i])) < 256) if ((size = strlen(argv[i])) < 256)
{ {
......
...@@ -974,11 +974,8 @@ void nxagentNotifySelection(XEvent *X) ...@@ -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) ...@@ -1500,11 +1497,8 @@ int nxagentInitClipboard(WindowPtr pWin)
fprintf(stderr, "nxagentInitClipboard: Got called.\n"); fprintf(stderr, "nxagentInitClipboard: Got called.\n");
#endif #endif
if (lastSelectionOwner != NULL) free(lastSelectionOwner);
{ lastSelectionOwner = NULL;
free(lastSelectionOwner);
lastSelectionOwner = NULL;
}
lastSelectionOwner = (SelectionOwner *) malloc(2 * sizeof(SelectionOwner)); lastSelectionOwner = (SelectionOwner *) malloc(2 * sizeof(SelectionOwner));
......
...@@ -257,8 +257,7 @@ void nxagentSetInstalledColormapWindows(ScreenPtr pScreen) ...@@ -257,8 +257,7 @@ void nxagentSetInstalledColormapWindows(ScreenPtr pScreen)
free(icws.cmapIDs); free(icws.cmapIDs);
if (!nxagentSameInstalledColormapWindows(icws.windows, icws.numWindows)) { if (!nxagentSameInstalledColormapWindows(icws.windows, icws.numWindows)) {
if (nxagentOldInstalledColormapWindows) free(nxagentOldInstalledColormapWindows);
free(nxagentOldInstalledColormapWindows);
#ifdef _XSERVER64 #ifdef _XSERVER64
{ {
...@@ -318,13 +317,12 @@ void nxagentSetInstalledColormapWindows(ScreenPtr pScreen) ...@@ -318,13 +317,12 @@ void nxagentSetInstalledColormapWindows(ScreenPtr pScreen)
#endif /* DUMB_WINDOW_MANAGERS */ #endif /* DUMB_WINDOW_MANAGERS */
} }
else else
if (icws.windows) free(icws.windows); free(icws.windows);
} }
void nxagentSetScreenSaverColormapWindow(ScreenPtr pScreen) void nxagentSetScreenSaverColormapWindow(ScreenPtr pScreen)
{ {
if (nxagentOldInstalledColormapWindows) free(nxagentOldInstalledColormapWindows);
free(nxagentOldInstalledColormapWindows);
#ifdef _XSERVER64 #ifdef _XSERVER64
{ {
......
...@@ -264,7 +264,7 @@ int nxagentSynchronizeDrawableData(DrawablePtr pDrawable, unsigned int breakMask ...@@ -264,7 +264,7 @@ int nxagentSynchronizeDrawableData(DrawablePtr pDrawable, unsigned int breakMask
success = 0; success = 0;
goto nxagentSynchronizeDrawableDataFree; goto nxagentSynchronizeDrawableDataEnd;
} }
ValidateGC(pDrawable, pGC); ValidateGC(pDrawable, pGC);
...@@ -282,7 +282,7 @@ int nxagentSynchronizeDrawableData(DrawablePtr pDrawable, unsigned int breakMask ...@@ -282,7 +282,7 @@ int nxagentSynchronizeDrawableData(DrawablePtr pDrawable, unsigned int breakMask
success = 1; success = 1;
goto nxagentSynchronizeDrawableDataFree; goto nxagentSynchronizeDrawableDataEnd;
} }
else if (nxagentReconnectTrap == 1) else if (nxagentReconnectTrap == 1)
{ {
...@@ -323,7 +323,7 @@ int nxagentSynchronizeDrawableData(DrawablePtr pDrawable, unsigned int breakMask ...@@ -323,7 +323,7 @@ int nxagentSynchronizeDrawableData(DrawablePtr pDrawable, unsigned int breakMask
success = 0; success = 0;
goto nxagentSynchronizeDrawableDataFree; goto nxagentSynchronizeDrawableDataEnd;
} }
ValidateGC(pDrawable, pGC); ValidateGC(pDrawable, pGC);
...@@ -336,7 +336,7 @@ int nxagentSynchronizeDrawableData(DrawablePtr pDrawable, unsigned int breakMask ...@@ -336,7 +336,7 @@ int nxagentSynchronizeDrawableData(DrawablePtr pDrawable, unsigned int breakMask
success = 1; success = 1;
goto nxagentSynchronizeDrawableDataFree; goto nxagentSynchronizeDrawableDataEnd;
} }
else else
{ {
...@@ -349,7 +349,7 @@ int nxagentSynchronizeDrawableData(DrawablePtr pDrawable, unsigned int breakMask ...@@ -349,7 +349,7 @@ int nxagentSynchronizeDrawableData(DrawablePtr pDrawable, unsigned int breakMask
success = 1; success = 1;
goto nxagentSynchronizeDrawableDataFree; goto nxagentSynchronizeDrawableDataEnd;
} }
} }
} }
...@@ -363,14 +363,8 @@ int nxagentSynchronizeDrawableData(DrawablePtr pDrawable, unsigned int breakMask ...@@ -363,14 +363,8 @@ int nxagentSynchronizeDrawableData(DrawablePtr pDrawable, unsigned int breakMask
success = nxagentSynchronizeRegion(pDrawable, NullRegion, breakMask, owner); success = nxagentSynchronizeRegion(pDrawable, NullRegion, breakMask, owner);
nxagentSynchronizeDrawableDataFree:
if (data != NULL)
{
free(data);
}
nxagentSynchronizeDrawableDataEnd: nxagentSynchronizeDrawableDataEnd:
free(data);
return success; return success;
} }
...@@ -866,10 +860,7 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned ...@@ -866,10 +860,7 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned
#endif #endif
} }
if (cmpData != NULL) free(cmpData);
{
free(cmpData);
}
} }
} }
else else
...@@ -1066,10 +1057,7 @@ nxagentSynchronizeRegionFree: ...@@ -1066,10 +1057,7 @@ nxagentSynchronizeRegionFree:
nxagentFreeRegion(pDrawable, clipRegion); nxagentFreeRegion(pDrawable, clipRegion);
} }
if (data != NULL) free(data);
{
free(data);
}
RegionUninit(&exposeRegion); RegionUninit(&exposeRegion);
......
...@@ -98,7 +98,7 @@ static char nxagentRootDir[DEFAULT_STRING_LENGTH] = { 0 }; ...@@ -98,7 +98,7 @@ static char nxagentRootDir[DEFAULT_STRING_LENGTH] = { 0 };
static char nxagentSessionDir[DEFAULT_STRING_LENGTH] = { 0 }; static char nxagentSessionDir[DEFAULT_STRING_LENGTH] = { 0 };
char *nxagentGetClientsPath(void); void nxagentGetClientsPath(void);
static int nxagentPrintError(Display *dpy, XErrorEvent *event, FILE *fp); static int nxagentPrintError(Display *dpy, XErrorEvent *event, FILE *fp);
...@@ -247,16 +247,9 @@ int nxagentExitHandler(const char *message) ...@@ -247,16 +247,9 @@ int nxagentExitHandler(const char *message)
void nxagentOpenClientsLogFile() void nxagentOpenClientsLogFile()
{ {
char * clientsLogName;
if (*nxagentClientsLogName == '\0') if (*nxagentClientsLogName == '\0')
{ {
clientsLogName = nxagentGetClientsPath(); nxagentGetClientsPath();
if (clientsLogName != NULL)
{
free(clientsLogName);
}
} }
if (nxagentClientsLogName != NULL && *nxagentClientsLogName !='\0') if (nxagentClientsLogName != NULL && *nxagentClientsLogName !='\0')
...@@ -593,30 +586,27 @@ char *nxagentGetSessionPath(void) ...@@ -593,30 +586,27 @@ char *nxagentGetSessionPath(void)
return sessionPath; return sessionPath;
} }
char *nxagentGetClientsPath() void nxagentGetClientsPath()
{ {
char *sessionPath;
char *clientsPath;
if (*nxagentClientsLogName == '\0') if (*nxagentClientsLogName == '\0')
{ {
sessionPath = nxagentGetSessionPath(); char *sessionPath = nxagentGetSessionPath();
if (sessionPath == NULL) if (sessionPath == NULL)
{ {
return NULL; return;
} }
if (strlen(sessionPath) + strlen("/clients") > DEFAULT_STRING_LENGTH - 1) if (strlen(sessionPath) + strlen("/clients") > DEFAULT_STRING_LENGTH - 1)
{ {
#ifdef PANIC #ifdef PANIC
fprintf(stderr, "nxagentGetClientsPath: PANIC! Invalid value for the NX clients Log File Path '%s'.\n", fprintf(stderr, "nxagentGetClientsPath: PANIC! Invalid value for the NX clients Log File Path ''.\n");
nxagentClientsLogName);
#endif #endif
free(sessionPath); free(sessionPath);
return NULL; return;
} }
strcpy(nxagentClientsLogName, sessionPath); strcpy(nxagentClientsLogName, sessionPath);
...@@ -626,19 +616,6 @@ char *nxagentGetClientsPath() ...@@ -626,19 +616,6 @@ char *nxagentGetClientsPath()
free(sessionPath); free(sessionPath);
} }
clientsPath = malloc(strlen(nxagentClientsLogName) + 1); return;
if (clientsPath == NULL)
{
#ifdef PANIC
fprintf(stderr, "nxagentGetClientsPath: PANIC! Can't allocate memory for the clients Log File Path path.\n");
#endif
return NULL;
}
strcpy(clientsPath, nxagentClientsLogName);
return clientsPath;
} }
...@@ -841,10 +841,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP ...@@ -841,10 +841,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP
for (j = 0; j < numSearchFields; j++) 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 ...@@ -863,10 +860,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP
for (j = 0; j < numFontFields; j++) for (j = 0; j < numFontFields; j++)
{ {
if (fontNameFields[j] != NULL) free(fontNameFields[j]);
{
free(fontNameFields[j]);
}
} }
return fontStruct; return fontStruct;
...@@ -1260,17 +1254,11 @@ static void nxagentFailedFontReconnect(FontPtr pFont, XID param1, void * param2) ...@@ -1260,17 +1254,11 @@ static void nxagentFailedFontReconnect(FontPtr pFont, XID param1, void * param2)
static void nxagentFreeFailedToReconnectFonts() 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.size = 0;
nxagentFailedToReconnectFonts.index = 0; nxagentFailedToReconnectFonts.index = 0;
...@@ -1706,10 +1694,7 @@ int nxagentFreeFont(XFontStruct *fs) ...@@ -1706,10 +1694,7 @@ int nxagentFreeFont(XFontStruct *fs)
#endif #endif
} }
if (fs -> properties) free (fs->properties);
{
free (fs->properties);
}
XFree(fs); XFree(fs);
......
...@@ -924,10 +924,7 @@ static void nxagentRestoreGCRec(struct nxagentGCRec *t) ...@@ -924,10 +924,7 @@ static void nxagentRestoreGCRec(struct nxagentGCRec *t)
(void*)t, (void*)t -> gc); (void*)t, (void*)t -> gc);
#endif #endif
if (nxagentGC(t -> pGC)) free(nxagentGC(t -> pGC));
{
free(nxagentGC(t -> pGC));
}
nxagentGC(t -> pGC) = t -> gc; nxagentGC(t -> pGC) = t -> gc;
......
...@@ -1545,10 +1545,7 @@ void nxagentFillPolygon(DrawablePtr pDrawable, GCPtr pGC, int shape, ...@@ -1545,10 +1545,7 @@ void nxagentFillPolygon(DrawablePtr pDrawable, GCPtr pGC, int shape,
RESET_GC_TRAP(); RESET_GC_TRAP();
} }
if (newPoints != NULL) free(newPoints);
{
free(newPoints);
}
} }
void nxagentPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, void nxagentPolyFillRect(DrawablePtr pDrawable, GCPtr pGC,
......
...@@ -1567,10 +1567,7 @@ nxagentPutSubImageEnd: ...@@ -1567,10 +1567,7 @@ nxagentPutSubImageEnd:
nxagentImageStatistics.totalEncoded, nxagentImageStatistics.totalAdded); nxagentImageStatistics.totalEncoded, nxagentImageStatistics.totalAdded);
#endif #endif
if (packedChecksum != NULL) free(packedChecksum);
{
free(packedChecksum);
}
if (packedImage != NULL) if (packedImage != NULL)
{ {
...@@ -1787,11 +1784,7 @@ int nxagentScaleImage(int x, int y, unsigned xRatio, unsigned yRatio, ...@@ -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); free((char *) image);
*pImage = newImage; *pImage = newImage;
......
...@@ -1172,10 +1172,7 @@ Bool nxagentCheckPixmapIntegrity(PixmapPtr pPixmap) ...@@ -1172,10 +1172,7 @@ Bool nxagentCheckPixmapIntegrity(PixmapPtr pPixmap)
XDestroyImage(image); XDestroyImage(image);
} }
if (data != NULL) free(data);
{
free(data);
}
} }
else else
{ {
...@@ -1421,10 +1418,7 @@ FIXME: If the pixmap has a different depth from the window, the ...@@ -1421,10 +1418,7 @@ FIXME: If the pixmap has a different depth from the window, the
fprintf(stderr, "nxagentPixmapOnShadowDisplay: XCreateImage failed.\n"); fprintf(stderr, "nxagentPixmapOnShadowDisplay: XCreateImage failed.\n");
#endif #endif
if (data != NULL) free(data);
{
free(data);
}
return False; return False;
} }
...@@ -1583,10 +1577,7 @@ Bool nxagentFbOnShadowDisplay() ...@@ -1583,10 +1577,7 @@ Bool nxagentFbOnShadowDisplay()
fprintf(stderr, "nxagentFbOnShadowDisplay: XCreateImage failed.\n"); fprintf(stderr, "nxagentFbOnShadowDisplay: XCreateImage failed.\n");
#endif #endif
if (data) free(data);
{
free(data);
}
return False; return False;
} }
......
...@@ -610,12 +610,8 @@ Bool nxagentReconnectSession(void) ...@@ -610,12 +610,8 @@ Bool nxagentReconnectSession(void)
nxagentXkbState.Initialized = 0; nxagentXkbState.Initialized = 0;
if (nxagentOldKeyboard != NULL) free(nxagentOldKeyboard);
{ nxagentOldKeyboard = NULL;
free(nxagentOldKeyboard);
nxagentOldKeyboard = NULL;
}
nxagentInitPointerMap(); nxagentInitPointerMap();
...@@ -739,12 +735,8 @@ nxagentReconnectError: ...@@ -739,12 +735,8 @@ nxagentReconnectError:
nxagentDisconnectDisplay(); nxagentDisconnectDisplay();
} }
if (nxagentOldKeyboard != NULL) free(nxagentOldKeyboard);
{ nxagentOldKeyboard = NULL;
free(nxagentOldKeyboard);
nxagentOldKeyboard = NULL;
}
return 0; return 0;
} }
......
...@@ -3079,10 +3079,7 @@ int nxagentShadowPoll(PixmapPtr nxagentShadowPixmapPtr, GCPtr nxagentShadowGCPtr ...@@ -3079,10 +3079,7 @@ int nxagentShadowPoll(PixmapPtr nxagentShadowPixmapPtr, GCPtr nxagentShadowGCPtr
length = nxagentImageLength(width, height, ZPixmap, 0, nxagentMasterDepth); length = nxagentImageLength(width, height, ZPixmap, 0, nxagentMasterDepth);
if (tBuffer) free(tBuffer);
{
free(tBuffer);
}
tBuffer = malloc(length); tBuffer = malloc(length);
...@@ -3139,10 +3136,7 @@ int nxagentShadowPoll(PixmapPtr nxagentShadowPixmapPtr, GCPtr nxagentShadowGCPtr ...@@ -3139,10 +3136,7 @@ int nxagentShadowPoll(PixmapPtr nxagentShadowPixmapPtr, GCPtr nxagentShadowGCPtr
RegionUnion(&nxagentShadowUpdateRegion, &nxagentShadowUpdateRegion, &updateRegion); RegionUnion(&nxagentShadowUpdateRegion, &nxagentShadowUpdateRegion, &updateRegion);
} }
if (tBuffer) free(tBuffer);
{
free(tBuffer);
}
RegionUninit(&updateRegion); RegionUninit(&updateRegion);
} }
...@@ -3360,10 +3354,7 @@ void nxagentShadowAdaptDepth(unsigned int width, unsigned int height, ...@@ -3360,10 +3354,7 @@ void nxagentShadowAdaptDepth(unsigned int width, unsigned int height,
cBuffer = (unsigned char *) *buffer; cBuffer = (unsigned char *) *buffer;
*buffer = (char *) icBuffer; *buffer = (char *) icBuffer;
if (cBuffer != NULL) free(cBuffer);
{
free(cBuffer);
}
} }
#ifdef NXAGENT_ARTSD #ifdef NXAGENT_ARTSD
...@@ -3826,9 +3817,8 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) ...@@ -3826,9 +3817,8 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen)
#endif #endif
number = 1; number = 1;
if (screeninfo) { free(screeninfo);
free(screeninfo);
}
if (!(screeninfo = malloc(sizeof(XineramaScreenInfo)))) { if (!(screeninfo = malloc(sizeof(XineramaScreenInfo)))) {
return FALSE; return FALSE;
} }
...@@ -4111,10 +4101,8 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) ...@@ -4111,10 +4101,8 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen)
} }
/* release allocated memory */ /* release allocated memory */
if (screeninfo) { free(screeninfo);
free(screeninfo); screeninfo = NULL;
screeninfo = NULL;
}
#ifdef DEBUG #ifdef DEBUG
for (i = 0; i < pScrPriv->numCrtcs; i++) { for (i = 0; i < pScrPriv->numCrtcs; i++) {
...@@ -4587,10 +4575,7 @@ FIXME ...@@ -4587,10 +4575,7 @@ FIXME
fprintf(stderr, "nxagentShowPixmap: XGetImage failed.\n"); fprintf(stderr, "nxagentShowPixmap: XGetImage failed.\n");
#endif #endif
if (data) free(data);
{
free(data);
}
return; return;
} }
...@@ -4623,10 +4608,7 @@ FIXME ...@@ -4623,10 +4608,7 @@ FIXME
XDestroyImage(image); XDestroyImage(image);
} }
if (data != NULL) free(data);
{
free(data);
}
/* /*
FIXME FIXME
...@@ -4678,10 +4660,7 @@ void nxagentFbRestoreArea(PixmapPtr pPixmap, WindowPtr pWin, int xSrc, int ySrc, ...@@ -4678,10 +4660,7 @@ void nxagentFbRestoreArea(PixmapPtr pPixmap, WindowPtr pWin, int xSrc, int ySrc,
fprintf(stderr, "nxagentFbRestoreArea: XGetImage failed.\n"); fprintf(stderr, "nxagentFbRestoreArea: XGetImage failed.\n");
#endif #endif
if (data) free(data);
{
free(data);
}
return; return;
} }
...@@ -4741,10 +4720,7 @@ FIXME ...@@ -4741,10 +4720,7 @@ FIXME
/* /*
FIXME FIXME
if (data) free(data);
{
free(data);
}
*/ */
} }
......
...@@ -3151,12 +3151,7 @@ FIXME: Do we need to set save unders attribute here? ...@@ -3151,12 +3151,7 @@ FIXME: Do we need to set save unders attribute here?
&hints); &hints);
#ifdef _XSERVER64 #ifdef _XSERVER64
free(data64);
if (data64 != NULL)
{
free(data64);
}
#endif #endif
} }
} }
...@@ -3404,10 +3399,7 @@ Bool nxagentCheckWindowIntegrity(WindowPtr pWin) ...@@ -3404,10 +3399,7 @@ Bool nxagentCheckWindowIntegrity(WindowPtr pWin)
XDestroyImage(image); XDestroyImage(image);
} }
if (data) free(data);
{
free(data);
}
} }
else else
{ {
...@@ -3947,11 +3939,8 @@ int nxagentEmptyBSPixmapList() ...@@ -3947,11 +3939,8 @@ int nxagentEmptyBSPixmapList()
for (i = 0; i < BSPIXMAPLIMIT; i++) for (i = 0; i < BSPIXMAPLIMIT; i++)
{ {
if (nxagentBSPixmapList[i] != NULL) free(nxagentBSPixmapList[i]);
{ nxagentBSPixmapList[i] = NULL;
free(nxagentBSPixmapList[i]);
nxagentBSPixmapList[i] = NULL;
}
} }
return 1; 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