Commit fc26b97e authored by walter harms's avatar walter harms Committed by Ulrich Sibiller

Remove redundant null checks before free

This patch removes some redundant null checks before free. It should not change the code otherwise. Be aware that this is only the first series. Signed-off-by: 's avatarHarms <wharms@bfs,de> Reviewed-by: 's avatarAlan Coopersmith <alan.coopersmith@oracle.com> Signed-off-by: 's avatarAlan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: 's avatarUlrich Sibiller <uli42@gmx.de>
parent 191d1575
...@@ -58,7 +58,7 @@ Status XFetchName ( ...@@ -58,7 +58,7 @@ Status XFetchName (
*name = (char *)data; *name = (char *)data;
return(1); return(1);
} }
if (data) Xfree (data); Xfree (data);
*name = NULL; *name = NULL;
return(0); return(0);
} }
...@@ -89,7 +89,7 @@ Status XGetIconName ( ...@@ -89,7 +89,7 @@ Status XGetIconName (
*icon_name = (char*)data; *icon_name = (char*)data;
return(1); return(1);
} }
if (data) Xfree (data); Xfree (data);
*icon_name = NULL; *icon_name = NULL;
return(0); return(0);
} }
...@@ -170,8 +170,8 @@ XFreeFont( ...@@ -170,8 +170,8 @@ XFreeFont(
#endif #endif
} }
_XFreeExtData(fs->ext_data); _XFreeExtData(fs->ext_data);
if (fs->properties)
Xfree (fs->properties); Xfree (fs->properties);
Xfree (fs); Xfree (fs);
return 1; return 1;
} }
...@@ -271,7 +271,7 @@ _XQueryFont ( ...@@ -271,7 +271,7 @@ _XQueryFont (
} }
} }
if (! fs->per_char) { if (! fs->per_char) {
if (fs->properties) Xfree(fs->properties); Xfree(fs->properties);
Xfree(fs); Xfree(fs);
_XEatDataWords(dpy, reply_left); _XEatDataWords(dpy, reply_left);
return (XFontStruct *)NULL; return (XFontStruct *)NULL;
...@@ -524,14 +524,14 @@ _XF86BigfontQueryFont ( ...@@ -524,14 +524,14 @@ _XF86BigfontQueryFont (
+ (reply.nCharInfos+1)/2 * 2 * sizeof(CARD16); + (reply.nCharInfos+1)/2 * 2 * sizeof(CARD16);
pUniqCI = Xmalloc (nbytes); pUniqCI = Xmalloc (nbytes);
if (!pUniqCI) { if (!pUniqCI) {
if (fs->properties) Xfree(fs->properties); Xfree(fs->properties);
Xfree(fs); Xfree(fs);
_XEatDataWords(dpy, reply_left); _XEatDataWords(dpy, reply_left);
return (XFontStruct *)NULL; return (XFontStruct *)NULL;
} }
if (! (fs->per_char = Xmalloc (reply.nCharInfos * sizeof(XCharStruct)))) { if (! (fs->per_char = Xmalloc (reply.nCharInfos * sizeof(XCharStruct)))) {
Xfree(pUniqCI); Xfree(pUniqCI);
if (fs->properties) Xfree(fs->properties); Xfree(fs->properties);
Xfree(fs); Xfree(fs);
_XEatDataWords(dpy, reply_left); _XEatDataWords(dpy, reply_left);
return (XFontStruct *)NULL; return (XFontStruct *)NULL;
...@@ -542,7 +542,7 @@ _XF86BigfontQueryFont ( ...@@ -542,7 +542,7 @@ _XF86BigfontQueryFont (
if (pIndex2UniqIndex[i] >= reply.nUniqCharInfos) { if (pIndex2UniqIndex[i] >= reply.nUniqCharInfos) {
fprintf(stderr, "_XF86BigfontQueryFont: server returned wrong data\n"); fprintf(stderr, "_XF86BigfontQueryFont: server returned wrong data\n");
Xfree(pUniqCI); Xfree(pUniqCI);
if (fs->properties) Xfree(fs->properties); Xfree(fs->properties);
Xfree(fs); Xfree(fs);
return (XFontStruct *)NULL; return (XFontStruct *)NULL;
} }
...@@ -558,7 +558,7 @@ _XF86BigfontQueryFont ( ...@@ -558,7 +558,7 @@ _XF86BigfontQueryFont (
pData = Xmalloc(sizeof(XExtData)); pData = Xmalloc(sizeof(XExtData));
if (!pData) { if (!pData) {
if (fs->properties) Xfree(fs->properties); Xfree(fs->properties);
Xfree(fs); Xfree(fs);
return (XFontStruct *)NULL; return (XFontStruct *)NULL;
} }
...@@ -578,7 +578,7 @@ _XF86BigfontQueryFont ( ...@@ -578,7 +578,7 @@ _XF86BigfontQueryFont (
if (extcodes->serverCapabilities & CAP_VerifiedLocal) if (extcodes->serverCapabilities & CAP_VerifiedLocal)
fprintf(stderr, "_XF86BigfontQueryFont: could not attach shm segment\n"); fprintf(stderr, "_XF86BigfontQueryFont: could not attach shm segment\n");
Xfree(pData); Xfree(pData);
if (fs->properties) Xfree(fs->properties); Xfree(fs->properties);
Xfree(fs); Xfree(fs);
/* Stop requesting shared memory transport from now on. */ /* Stop requesting shared memory transport from now on. */
extcodes->serverCapabilities &= ~ XF86Bigfont_CAP_LocalShm; extcodes->serverCapabilities &= ~ XF86Bigfont_CAP_LocalShm;
...@@ -593,7 +593,7 @@ _XF86BigfontQueryFont ( ...@@ -593,7 +593,7 @@ _XF86BigfontQueryFont (
&& *(CARD32 *)(addr + reply.shmsegoffset + reply.nCharInfos * sizeof(XCharStruct)) == extcodes->serverSignature)) { && *(CARD32 *)(addr + reply.shmsegoffset + reply.nCharInfos * sizeof(XCharStruct)) == extcodes->serverSignature)) {
shmdt(addr); shmdt(addr);
Xfree(pData); Xfree(pData);
if (fs->properties) Xfree(fs->properties); Xfree(fs->properties);
Xfree(fs); Xfree(fs);
/* Stop requesting shared memory transport from now on. */ /* Stop requesting shared memory transport from now on. */
extcodes->serverCapabilities &= ~ XF86Bigfont_CAP_LocalShm; extcodes->serverCapabilities &= ~ XF86Bigfont_CAP_LocalShm;
...@@ -697,8 +697,8 @@ int _XF86LoadQueryLocaleFont( ...@@ -697,8 +697,8 @@ int _XF86LoadQueryLocaleFont(
#endif #endif
} }
_XFreeExtData(fs->ext_data); _XFreeExtData(fs->ext_data);
if (fs->properties)
Xfree (fs->properties); Xfree (fs->properties);
*fidp = fs->fid; *fidp = fs->fid;
Xfree (fs); Xfree (fs);
} else { } else {
......
...@@ -179,8 +179,8 @@ XFontStruct **info) /* RETURN */ ...@@ -179,8 +179,8 @@ XFontStruct **info) /* RETURN */
Xfree(flist[j]); Xfree(flist[j]);
if (finfo[j].properties) Xfree(finfo[j].properties); if (finfo[j].properties) Xfree(finfo[j].properties);
} }
if (flist) Xfree(flist); Xfree(flist);
if (finfo) Xfree(finfo); Xfree(finfo);
clearwire: clearwire:
/* Clear the wire. */ /* Clear the wire. */
......
...@@ -73,8 +73,8 @@ int *actualCount) /* RETURN */ ...@@ -73,8 +73,8 @@ int *actualCount) /* RETURN */
} }
if ((! flist) || (! ch)) { if ((! flist) || (! ch)) {
if (flist) Xfree(flist); Xfree(flist);
if (ch) Xfree(ch); Xfree(ch);
_XEatDataWords(dpy, rep.length); _XEatDataWords(dpy, rep.length);
*actualCount = 0; *actualCount = 0;
UnlockDisplay(dpy); UnlockDisplay(dpy);
......
...@@ -57,8 +57,8 @@ char **XGetFontPath( ...@@ -57,8 +57,8 @@ char **XGetFontPath(
} }
if ((! flist) || (! ch)) { if ((! flist) || (! ch)) {
if (flist) Xfree(flist); Xfree(flist);
if (ch) Xfree(ch); Xfree(ch);
_XEatDataWords(dpy, rep.length); _XEatDataWords(dpy, rep.length);
UnlockDisplay(dpy); UnlockDisplay(dpy);
SyncHandle(); SyncHandle();
......
...@@ -75,7 +75,7 @@ Status XGetSizeHints ( ...@@ -75,7 +75,7 @@ Status XGetSizeHints (
if ((actual_type != XA_WM_SIZE_HINTS) || if ((actual_type != XA_WM_SIZE_HINTS) ||
(nitems < OldNumPropSizeElements) || (actual_format != 32)) { (nitems < OldNumPropSizeElements) || (actual_format != 32)) {
if (prop != NULL) Xfree (prop); Xfree (prop);
return(0); return(0);
} }
hints->flags = (prop->flags & (USPosition|USSize|PAllHints)); hints->flags = (prop->flags & (USPosition|USSize|PAllHints));
...@@ -124,7 +124,7 @@ XWMHints *XGetWMHints ( ...@@ -124,7 +124,7 @@ XWMHints *XGetWMHints (
if ((actual_type != XA_WM_HINTS) || if ((actual_type != XA_WM_HINTS) ||
(nitems < (NumPropWMHintsElements - 1)) || (actual_format != 32)) { (nitems < (NumPropWMHintsElements - 1)) || (actual_format != 32)) {
if (prop != NULL) Xfree (prop); Xfree (prop);
return(NULL); return(NULL);
} }
/* static copies not allowed in library, due to reentrancy constraint*/ /* static copies not allowed in library, due to reentrancy constraint*/
...@@ -196,7 +196,7 @@ Status XGetIconSizes ( ...@@ -196,7 +196,7 @@ Status XGetIconSizes (
(nitems < NumPropIconSizeElements) || (nitems < NumPropIconSizeElements) ||
(nitems % NumPropIconSizeElements != 0) || (nitems % NumPropIconSizeElements != 0) ||
(actual_format != 32)) { (actual_format != 32)) {
if (prop != NULL) Xfree (prop); Xfree (prop);
return(0); return(0);
} }
...@@ -204,7 +204,7 @@ Status XGetIconSizes ( ...@@ -204,7 +204,7 @@ Status XGetIconSizes (
nitems /= NumPropIconSizeElements; nitems /= NumPropIconSizeElements;
if (! (hp = hints = Xcalloc (nitems, sizeof(XIconSize)))) { if (! (hp = hints = Xcalloc (nitems, sizeof(XIconSize)))) {
if (prop) Xfree (prop); Xfree (prop);
return 0; return 0;
} }
...@@ -239,7 +239,7 @@ Status XGetCommand ( ...@@ -239,7 +239,7 @@ Status XGetCommand (
if (!XGetTextProperty (dpy, w, &tp, XA_WM_COMMAND)) return 0; if (!XGetTextProperty (dpy, w, &tp, XA_WM_COMMAND)) return 0;
if (tp.encoding != XA_STRING || tp.format != 8) { if (tp.encoding != XA_STRING || tp.format != 8) {
if (tp.value) Xfree (tp.value); Xfree (tp.value);
return 0; return 0;
} }
...@@ -254,7 +254,7 @@ Status XGetCommand ( ...@@ -254,7 +254,7 @@ Status XGetCommand (
* create a string list and return if successful * create a string list and return if successful
*/ */
if (!XTextPropertyToStringList (&tp, &argv, &argc)) { if (!XTextPropertyToStringList (&tp, &argv, &argc)) {
if (tp.value) Xfree (tp.value); Xfree (tp.value);
return (0); return (0);
} }
...@@ -291,7 +291,7 @@ XGetTransientForHint( ...@@ -291,7 +291,7 @@ XGetTransientForHint(
return (1); return (1);
} }
*propWindow = None; *propWindow = None;
if (data) Xfree( (char *) data); Xfree( (char *) data);
return(0); return(0);
} }
...@@ -333,6 +333,6 @@ XGetClassHint( ...@@ -333,6 +333,6 @@ XGetClassHint(
Xfree( (char *) data); Xfree( (char *) data);
return(1); return(1);
} }
if (data) Xfree( (char *) data); Xfree( (char *) data);
return(0); return(0);
} }
...@@ -83,7 +83,7 @@ Status XGetWMSizeHints ( ...@@ -83,7 +83,7 @@ Status XGetWMSizeHints (
if ((actual_type != XA_WM_SIZE_HINTS) || if ((actual_type != XA_WM_SIZE_HINTS) ||
(nitems < OldNumPropSizeElements) || (actual_format != 32)) { (nitems < OldNumPropSizeElements) || (actual_format != 32)) {
if (prop != NULL) Xfree (prop); Xfree (prop);
return False; return False;
} }
......
...@@ -63,7 +63,7 @@ Status XGetRGBColormaps ( ...@@ -63,7 +63,7 @@ Status XGetRGBColormaps (
/* if wrong type or format, or too small for us, then punt */ /* if wrong type or format, or too small for us, then punt */
if ((actual_type != XA_RGB_COLOR_MAP) || (actual_format != 32) || if ((actual_type != XA_RGB_COLOR_MAP) || (actual_format != 32) ||
(nitems < OldNumPropStandardColormapElements)) { (nitems < OldNumPropStandardColormapElements)) {
if (data) Xfree (data); Xfree (data);
return False; return False;
} }
...@@ -78,7 +78,7 @@ Status XGetRGBColormaps ( ...@@ -78,7 +78,7 @@ Status XGetRGBColormaps (
Screen *sp = _XScreenOfWindow (dpy, w); Screen *sp = _XScreenOfWindow (dpy, w);
if (!sp) { if (!sp) {
if (data) Xfree (data); Xfree (data);
return False; return False;
} }
def_visual = sp->root_visual->visualid; def_visual = sp->root_visual->visualid;
...@@ -90,7 +90,7 @@ Status XGetRGBColormaps ( ...@@ -90,7 +90,7 @@ Status XGetRGBColormaps (
ncmaps = (nitems / NumPropStandardColormapElements); ncmaps = (nitems / NumPropStandardColormapElements);
if ((((unsigned long) ncmaps) * NumPropStandardColormapElements) != if ((((unsigned long) ncmaps) * NumPropStandardColormapElements) !=
nitems) { nitems) {
if (data) Xfree (data); Xfree (data);
return False; return False;
} }
} }
...@@ -101,7 +101,7 @@ Status XGetRGBColormaps ( ...@@ -101,7 +101,7 @@ Status XGetRGBColormaps (
*/ */
cmaps = Xmalloc (ncmaps * sizeof (XStandardColormap)); cmaps = Xmalloc (ncmaps * sizeof (XStandardColormap));
if (!cmaps) { if (!cmaps) {
if (data) Xfree (data); Xfree (data);
return False; return False;
} }
......
...@@ -81,7 +81,7 @@ Status XGetStandardColormap ( ...@@ -81,7 +81,7 @@ Status XGetStandardColormap (
int i; int i;
if (!sp) { if (!sp) {
if (stdcmaps) Xfree (stdcmaps); Xfree (stdcmaps);
return False; return False;
} }
vid = sp->root_visual->visualid; vid = sp->root_visual->visualid;
......
...@@ -77,7 +77,7 @@ Status XGetWMColormapWindows ( ...@@ -77,7 +77,7 @@ Status XGetWMColormapWindows (
return False; return False;
if (actual_type != XA_WINDOW || actual_format != 32) { if (actual_type != XA_WINDOW || actual_format != 32) {
if (data) Xfree (data); Xfree (data);
return False; return False;
} }
......
...@@ -434,8 +434,8 @@ Status XInitImage (XImage *image) ...@@ -434,8 +434,8 @@ Status XInitImage (XImage *image)
static int _XDestroyImage (XImage *ximage) static int _XDestroyImage (XImage *ximage)
{ {
if (ximage->data != NULL) Xfree(ximage->data); Xfree(ximage->data);
if (ximage->obdata != NULL) Xfree(ximage->obdata); Xfree(ximage->obdata);
Xfree(ximage); Xfree(ximage);
return 1; return 1;
} }
......
...@@ -51,7 +51,7 @@ XExtCodes *XInitExtension ( ...@@ -51,7 +51,7 @@ XExtCodes *XInitExtension (
LockDisplay (dpy); LockDisplay (dpy);
if (! (ext = Xcalloc (1, sizeof (_XExtension))) || if (! (ext = Xcalloc (1, sizeof (_XExtension))) ||
! (ext->name = strdup(name))) { ! (ext->name = strdup(name))) {
if (ext) Xfree(ext); Xfree(ext);
UnlockDisplay(dpy); UnlockDisplay(dpy);
return (XExtCodes *) NULL; return (XExtCodes *) NULL;
} }
......
...@@ -271,12 +271,13 @@ _XKeyInitialize( ...@@ -271,12 +271,13 @@ _XKeyInitialize(
if (! keysyms) return 0; if (! keysyms) return 0;
LockDisplay(dpy); LockDisplay(dpy);
if (dpy->keysyms)
Xfree (dpy->keysyms); Xfree (dpy->keysyms);
dpy->keysyms = keysyms; dpy->keysyms = keysyms;
dpy->keysyms_per_keycode = per; dpy->keysyms_per_keycode = per;
if (dpy->modifiermap) if (dpy->modifiermap)
ResetModMap(dpy); ResetModMap(dpy);
UnlockDisplay(dpy); UnlockDisplay(dpy);
} }
if (!dpy->modifiermap) if (!dpy->modifiermap)
...@@ -929,8 +930,8 @@ XRebindKeysym ( ...@@ -929,8 +930,8 @@ XRebindKeysym (
((! (p->string = Xmalloc(nbytes))) && (nbytes > 0)) || ((! (p->string = Xmalloc(nbytes))) && (nbytes > 0)) ||
((! (p->modifiers = Xmalloc(nb))) && (nb > 0))) { ((! (p->modifiers = Xmalloc(nb))) && (nb > 0))) {
if (p) { if (p) {
if (p->string) Xfree(p->string); Xfree(p->string);
if (p->modifiers) Xfree(p->modifiers); Xfree(p->modifiers);
Xfree(p); Xfree(p);
} }
UnlockDisplay(dpy); UnlockDisplay(dpy);
......
...@@ -62,8 +62,8 @@ char **XListExtensions( ...@@ -62,8 +62,8 @@ char **XListExtensions(
} }
if ((!list) || (!ch)) { if ((!list) || (!ch)) {
if (list) Xfree(list); Xfree(list);
if (ch) Xfree(ch); Xfree(ch);
_XEatDataWords(dpy, rep.length); _XEatDataWords(dpy, rep.length);
UnlockDisplay(dpy); UnlockDisplay(dpy);
SyncHandle(); SyncHandle();
......
...@@ -50,7 +50,7 @@ XGetModifierMapping(register Display *dpy) ...@@ -50,7 +50,7 @@ XGetModifierMapping(register Display *dpy)
} else } else
res = NULL; res = NULL;
if ((! res) || (! res->modifiermap)) { if ((! res) || (! res->modifiermap)) {
if (res) Xfree(res); Xfree(res);
res = (XModifierKeymap *) NULL; res = (XModifierKeymap *) NULL;
_XEatDataWords(dpy, rep.length); _XEatDataWords(dpy, rep.length);
} else { } else {
...@@ -114,8 +114,7 @@ int ...@@ -114,8 +114,7 @@ int
XFreeModifiermap(XModifierKeymap *map) XFreeModifiermap(XModifierKeymap *map)
{ {
if (map) { if (map) {
if (map->modifiermap) Xfree(map->modifiermap);
Xfree(map->modifiermap);
Xfree(map); Xfree(map);
} }
return 1; return 1;
......
...@@ -864,8 +864,7 @@ void _XFreeDisplayStructure(Display *dpy) ...@@ -864,8 +864,7 @@ void _XFreeDisplayStructure(Display *dpy)
while (dpy->ext_procs) { while (dpy->ext_procs) {
_XExtension *ext = dpy->ext_procs; _XExtension *ext = dpy->ext_procs;
dpy->ext_procs = ext->next; dpy->ext_procs = ext->next;
if (ext->name) Xfree (ext->name);
Xfree (ext->name);
Xfree (ext); Xfree (ext);
} }
if (dpy->im_filters) if (dpy->im_filters)
...@@ -929,25 +928,18 @@ void _XFreeDisplayStructure(Display *dpy) ...@@ -929,25 +928,18 @@ void _XFreeDisplayStructure(Display *dpy)
Xfree (dpy->pixmap_format); Xfree (dpy->pixmap_format);
} }
if (dpy->display_name) free(dpy->display_name);
Xfree (dpy->display_name);
if (dpy->vendor)
Xfree (dpy->vendor);
if (dpy->buffer) Xfree (dpy->vendor);
Xfree (dpy->buffer); Xfree (dpy->buffer);
if (dpy->keysyms) Xfree (dpy->keysyms);
Xfree (dpy->keysyms); Xfree (dpy->xdefaults);
if (dpy->xdefaults) Xfree (dpy->error_vec);
Xfree (dpy->xdefaults);
if (dpy->error_vec)
Xfree (dpy->error_vec);
_XFreeExtData (dpy->ext_data); _XFreeExtData (dpy->ext_data);
if (dpy->free_funcs)
Xfree (dpy->free_funcs); Xfree (dpy->free_funcs);
if (dpy->scratch_buffer) Xfree (dpy->scratch_buffer);
Xfree (dpy->scratch_buffer);
FreeDisplayLock(dpy); FreeDisplayLock(dpy);
if (dpy->qfree) { if (dpy->qfree) {
...@@ -962,8 +954,7 @@ void _XFreeDisplayStructure(Display *dpy) ...@@ -962,8 +954,7 @@ void _XFreeDisplayStructure(Display *dpy)
while (dpy->im_fd_info) { while (dpy->im_fd_info) {
struct _XConnectionInfo *conni = dpy->im_fd_info; struct _XConnectionInfo *conni = dpy->im_fd_info;
dpy->im_fd_info = conni->next; dpy->im_fd_info = conni->next;
if (conni->watch_data) Xfree (conni->watch_data);
Xfree (conni->watch_data);
Xfree (conni); Xfree (conni);
} }
if (dpy->conn_watchers) { if (dpy->conn_watchers) {
...@@ -971,8 +962,8 @@ void _XFreeDisplayStructure(Display *dpy) ...@@ -971,8 +962,8 @@ void _XFreeDisplayStructure(Display *dpy)
dpy->conn_watchers = watcher->next; dpy->conn_watchers = watcher->next;
Xfree (watcher); Xfree (watcher);
} }
if (dpy->filedes)
Xfree (dpy->filedes); Xfree (dpy->filedes);
#if USE_XCB #if USE_XCB
_XFreeX11XCBStructure(dpy); _XFreeX11XCBStructure(dpy);
......
...@@ -740,8 +740,7 @@ SendXYImage( ...@@ -740,8 +740,7 @@ SendXYImage(
bytes_per_src, bytes_per_line, bytes_per_src, bytes_per_line,
bytes_per_dest, req->height, half_order); bytes_per_dest, req->height, half_order);
if (extra) Xfree(extra);
Xfree(extra);
if (buf == dpy->bufptr) if (buf == dpy->bufptr)
dpy->bufptr += length; dpy->bufptr += length;
...@@ -793,8 +792,7 @@ SendZImage( ...@@ -793,8 +792,7 @@ SendZImage(
((req_xoffset == 0) || ((req_xoffset == 0) ||
((req_yoffset + req->height) < (unsigned)image->height))) { ((req_yoffset + req->height) < (unsigned)image->height))) {
Data(dpy, (char *)src, length); Data(dpy, (char *)src, length);
if (shifted_src) Xfree(shifted_src);
Xfree(shifted_src);
return; return;
} }
...@@ -804,7 +802,7 @@ SendZImage( ...@@ -804,7 +802,7 @@ SendZImage(
else else
if ((dest = (unsigned char *) if ((dest = (unsigned char *)
_XAllocScratch(dpy, length)) == NULL) { _XAllocScratch(dpy, length)) == NULL) {
if (shifted_src) Xfree(shifted_src); Xfree(shifted_src);
UnGetReq(PutImage); UnGetReq(PutImage);
return; return;
} }
...@@ -831,8 +829,7 @@ SendZImage( ...@@ -831,8 +829,7 @@ SendZImage(
else else
_XSend(dpy, (char *)dest, length); _XSend(dpy, (char *)dest, length);
if (shifted_src) Xfree(shifted_src);
Xfree(shifted_src);
} }
static void static void
......
...@@ -137,7 +137,7 @@ XReadBitmapFileData ( ...@@ -137,7 +137,7 @@ XReadBitmapFileData (
/* error cleanup and return macro */ /* error cleanup and return macro */
#define RETURN(code) \ #define RETURN(code) \
{ if (bits) Xfree (bits); fclose (fstream); return code; } { Xfree (bits); fclose (fstream); return code; }
while (fgets(line, MAX_SIZE, fstream)) { while (fgets(line, MAX_SIZE, fstream)) {
if (strlen(line) == MAX_SIZE-1) if (strlen(line) == MAX_SIZE-1)
......
...@@ -48,8 +48,7 @@ char *XScreenResourceString(Screen *screen) ...@@ -48,8 +48,7 @@ char *XScreenResourceString(Screen *screen)
(unsigned char **) &val) == Success) { (unsigned char **) &val) == Success) {
if ((actual_type == XA_STRING) && (actual_format == 8)) if ((actual_type == XA_STRING) && (actual_format == 8))
return val; return val;
if (val) Xfree(val);
Xfree(val);
} }
return (char *)NULL; return (char *)NULL;
} }
...@@ -74,7 +74,7 @@ char *XFetchBuffer ( ...@@ -74,7 +74,7 @@ char *XFetchBuffer (
*nbytes = nitems; *nbytes = nitems;
return((char *)data); return((char *)data);
} }
if ((char *) data != NULL) Xfree (data); Xfree (data);
return(NULL); return(NULL);
} }
......
...@@ -2537,8 +2537,7 @@ _XUnregisterInternalConnection( ...@@ -2537,8 +2537,7 @@ _XUnregisterInternalConnection(
watch=watch->next, wd++) { watch=watch->next, wd++) {
(*watch->fn) (dpy, watch->client_data, fd, False, wd); (*watch->fn) (dpy, watch->client_data, fd, False, wd);
} }
if (info_list->watch_data) Xfree (info_list->watch_data);
Xfree (info_list->watch_data);
Xfree (info_list); Xfree (info_list);
break; break;
} }
...@@ -3763,9 +3762,10 @@ char *_XAllocScratch( ...@@ -3763,9 +3762,10 @@ char *_XAllocScratch(
unsigned long nbytes) unsigned long nbytes)
{ {
if (nbytes > dpy->scratch_length) { if (nbytes > dpy->scratch_length) {
if (dpy->scratch_buffer) Xfree (dpy->scratch_buffer); Xfree (dpy->scratch_buffer);
if ((dpy->scratch_buffer = Xmalloc(nbytes))) dpy->scratch_buffer = Xmalloc(nbytes);
dpy->scratch_length = nbytes; if (dpy->scratch_buffer)
dpy->scratch_length = nbytes;
else dpy->scratch_length = 0; else dpy->scratch_length = 0;
} }
return (dpy->scratch_buffer); return (dpy->scratch_buffer);
...@@ -3792,8 +3792,8 @@ void _XFreeTemp( ...@@ -3792,8 +3792,8 @@ void _XFreeTemp(
char *buf, char *buf,
unsigned long nbytes) unsigned long nbytes)
{ {
if (dpy->scratch_buffer)
Xfree(dpy->scratch_buffer); Xfree(dpy->scratch_buffer);
dpy->scratch_buffer = buf; dpy->scratch_buffer = buf;
dpy->scratch_length = nbytes; dpy->scratch_length = nbytes;
} }
......
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