diff --git a/dox/dox.c b/dox/dox.c index 09bee230..3d57e5ed 100644 --- a/dox/dox.c +++ b/dox/dox.c @@ -243,8 +243,8 @@ while (ll) \ { \ l = ll; \ ll = ll->next; \ - free(l->name); \ - free(l); \ + Efree(l->name); \ + Efree(l); \ } #define UPDATE_NOW \ @@ -572,7 +572,7 @@ main(int argc, char **argv) dirlen = sp - exe; if (dirlen > 1) { - free(docdir); + Efree(docdir); docdir = EMALLOC(char, dirlen + 1); memcpy(docdir, exe, dirlen); @@ -580,8 +580,7 @@ main(int argc, char **argv) } GetObjects(p); pclose(p); - if (page_hist) - free(page_hist); + Efree(page_hist); page_hist = EMALLOC(int, 1); page_hist[0] = 0; diff --git a/dox/dox.h b/dox/dox.h index d36f219e..128c47f7 100644 --- a/dox/dox.h +++ b/dox/dox.h @@ -146,9 +146,13 @@ extern Display *disp; extern Root VRoot; extern char *docdir; -#define Efree free #define Emalloc malloc #define Erealloc realloc +#if HAVE_FREE_NULL_BUG +#define Efree(p) if (p) free(p) +#else +#define Efree free +#endif #define EMALLOC(type, num) (type*)Emalloc((num)*sizeof(type)) #define EREALLOC(type, ptr, num) (type*)Erealloc(ptr, (num)*sizeof(type)) diff --git a/dox/file.c b/dox/file.c index 318ca285..e80721bf 100644 --- a/dox/file.c +++ b/dox/file.c @@ -44,10 +44,8 @@ freestrlist(char **l, int num) if (!l) return; while (num--) - if (l[num]) - free(l[num]); - free(l); - return; + Efree(l[num]); + Efree(l); } void @@ -110,7 +108,6 @@ word(char *s, int num, char *wd) } *wd = 0; } - return; } #ifdef USE_WORD_MB @@ -265,7 +262,6 @@ word_mb(char *s, int num, char *wd, int *spaceflag) } *wd = 0; } - return; } #endif @@ -294,14 +290,14 @@ findLocalizedFile(char *fname) sprintf(fname, "%s.%s", tmp, lang); if (exists(fname)) { - free(tmp); - free(lang); + Efree(tmp); + Efree(lang); return 1; } } strcpy(fname, tmp); - free(tmp); - free(lang); + Efree(tmp); + Efree(lang); return 0; } diff --git a/dox/format.c b/dox/format.c index 0df608f2..abee9e31 100644 --- a/dox/format.c +++ b/dox/format.c @@ -423,29 +423,22 @@ GetObjects(FILE * f) { int j; - if (page[i].name) - free(page[i].name); - if (page[i].background) - free(page[i].background); + Efree(page[i].name); + Efree(page[i].background); for (j = 0; j < page[i].count; j++) { switch (page[i].obj[j].type) { case IMG: - if (((Img_ *) page[i].obj[j].object)->src) - free(((Img_ *) page[i].obj[j].object)->src); - if (((Img_ *) page[i].obj[j].object)->src2) - free(((Img_ *) page[i].obj[j].object)->src2); - if (((Img_ *) page[i].obj[j].object)->src3) - free(((Img_ *) page[i].obj[j].object)->src3); - if (((Img_ *) page[i].obj[j].object)->link) - free(((Img_ *) page[i].obj[j].object)->link); + Efree(((Img_ *) page[i].obj[j].object)->src); + Efree(((Img_ *) page[i].obj[j].object)->src2); + Efree(((Img_ *) page[i].obj[j].object)->src3); + Efree(((Img_ *) page[i].obj[j].object)->link); break; case BR: break; case FONT: - if (((Font_ *) page[i].obj[j].object)->face) - free(((Font_ *) page[i].obj[j].object)->face); + Efree(((Font_ *) page[i].obj[j].object)->face); break; case P: break; @@ -454,13 +447,11 @@ GetObjects(FILE * f) case PAGE: break; } - if (page[i].obj[j].object) - free(page[i].obj[j].object); + Efree(page[i].obj[j].object); } - if (page[i].obj) - free(page[i].obj); + Efree(page[i].obj); } - free(page); + Efree(page); num_pages = 0; page = NULL; have_font = 0; @@ -482,8 +473,7 @@ GetObjects(FILE * f) { if (!GetNextTag(&obj)) { - if (fdat) - free(fdat); + Efree(fdat); return 0; } } @@ -492,8 +482,7 @@ GetObjects(FILE * f) { if (!GetNextTag(&obj)) { - if (fdat) - free(fdat); + Efree(fdat); return 0; } } @@ -513,7 +502,7 @@ GetObjects(FILE * f) have_font = 1; obj.object = NULL; } - free(fdat); + Efree(fdat); } int diff --git a/dox/text.c b/dox/text.c index fa1a3c20..b98c7eab 100644 --- a/dox/text.c +++ b/dox/text.c @@ -91,8 +91,7 @@ TextStateLoadFont(TextState * ts) ts->height = as + ds; } } - if (s2) - free(s2); + Efree(s2); if (ts->efont) return; } diff --git a/eesh/E.h b/eesh/E.h index a5013c50..661298e2 100644 --- a/eesh/E.h +++ b/eesh/E.h @@ -55,9 +55,13 @@ void ClientDestroy(Client * c); void Alert(const char *fmt, ...); #define Ecalloc calloc -#define Efree free #define Emalloc malloc #define Erealloc realloc +#if HAVE_FREE_NULL_BUG +#define Efree(p) if (p) free(p) +#else +#define Efree free +#endif #define EMALLOC(type, num) (type*)Emalloc((num)*sizeof(type)) #define EREALLOC(type, ptr, num) (type*)Erealloc(ptr, (num)*sizeof(type)) diff --git a/eesh/comms.c b/eesh/comms.c index 920899d9..b59b1556 100644 --- a/eesh/comms.c +++ b/eesh/comms.c @@ -190,7 +190,6 @@ ClientDestroy(Client * c) if (!c) return; - if (c->msg) - Efree(c->msg); + Efree(c->msg); Efree(c); } diff --git a/src/aclass.c b/src/aclass.c index 070f5954..2e7dbfca 100644 --- a/src/aclass.c +++ b/src/aclass.c @@ -79,8 +79,7 @@ RemoveActionType(ActionType * ActionTypeToRemove) ptr = ActionTypeToRemove; while (ptr) { - if (ptr->params) - Efree(ptr->params); + Efree(ptr->params); pp = ptr; ptr = ptr->next; Efree(pp); @@ -123,10 +122,8 @@ ActionDestroy(Action * aa) UnGrabActionKey(aa); if (aa->action) RemoveActionType(aa->action); - if (aa->tooltipstring) - Efree(aa->tooltipstring); - if (aa->key_str) - Efree(aa->key_str); + Efree(aa->tooltipstring); + Efree(aa->key_str); Efree(aa); } @@ -211,12 +208,9 @@ ActionclassDestroy(ActionClass * ac) for (i = 0; i < ac->num; i++) ActionDestroy(ac->list[i]); - if (ac->list) - Efree(ac->list); - if (ac->name) - Efree(ac->name); - if (ac->tooltipstring) - Efree(ac->tooltipstring); + Efree(ac->list); + Efree(ac->name); + Efree(ac->tooltipstring); Efree(ac); mode_action_destroy = 1; } @@ -306,8 +300,6 @@ AclassConfigLoad(FILE * fs) (aclass_tooltipstring) ? Estrdup((aclass_tooltipstring[0]) ? aclass_tooltipstring : "?!?") : NULL; - _EFREE(aclass_tooltipstring); - _EFREE(action_tooltipstring); err = 0; goto done; @@ -457,7 +449,8 @@ AclassConfigLoad(FILE * fs) aa = ActionCreate(event, anymod, mod, anybut, but, anykey, key, action_tooltipstring); /* the correct place to grab an action key */ - _EFREE(action_tooltipstring); + Efree(action_tooltipstring); + action_tooltipstring = NULL; key[0] = '\0'; if (global) GrabActionKey(aa); @@ -482,8 +475,8 @@ AclassConfigLoad(FILE * fs) ActionclassDestroy(ac); done: - _EFREE(aclass_tooltipstring); - _EFREE(action_tooltipstring); + Efree(aclass_tooltipstring); + Efree(action_tooltipstring); return err; } diff --git a/src/alert.c b/src/alert.c index 7d2db25d..f94bee07 100644 --- a/src/alert.c +++ b/src/alert.c @@ -536,12 +536,9 @@ ShowAlert(const char *title, } done: - if (str1) - Efree(str1); - if (str2) - Efree(str2); - if (str3) - Efree(str3); + Efree(str1); + Efree(str2); + Efree(str3); } void diff --git a/src/arrange.c b/src/arrange.c index 4bf39b01..adc47554 100644 --- a/src/arrange.c +++ b/src/arrange.c @@ -424,14 +424,10 @@ ArrangeRects(const RectBox * fixed, int fixed_count, RectBox * floating, done: /* free up memory */ - if (xarray) - Efree(xarray); - if (yarray) - Efree(yarray); - if (filled) - Efree(filled); - if (spaces) - Efree(spaces); + Efree(xarray); + Efree(yarray); + Efree(filled); + Efree(spaces); } void @@ -638,8 +634,7 @@ SnapEwin(EWin * ewin, int dx, int dy, int *new_dx, int *new_dy) dy = 0; } - if (lst) - Efree(lst); + Efree(lst); if ((odx != dx) || (ody != dy)) { @@ -851,10 +846,8 @@ ArrangeEwinXY(EWin * ewin, int *px, int *py) break; } } - if (ret) - Efree(ret); - if (fixed) - Efree(fixed); + Efree(ret); + Efree(fixed); } void @@ -918,12 +911,9 @@ ArrangeEwins(const char *params) EwinMove(ewin, ret[i].x, ret[i].y); } - if (fixed) - Efree(fixed); - if (ret) - Efree(ret); - if (floating) - Efree(floating); + Efree(fixed); + Efree(ret); + Efree(floating); done: return; diff --git a/src/backgrounds.c b/src/backgrounds.c index e7f77d49..e0a8de6d 100644 --- a/src/backgrounds.c +++ b/src/backgrounds.c @@ -210,20 +210,16 @@ BackgroundImagesKeep(Background * bg, int onoff) static void BackgroundFilesRemove(Background * bg) { - if (bg->bg.file) - Efree(bg->bg.file); + Efree(bg->bg.file); bg->bg.file = NULL; - if (bg->bg.real_file) - Efree(bg->bg.real_file); + Efree(bg->bg.real_file); bg->bg.real_file = NULL; - if (bg->top.file) - Efree(bg->top.file); + Efree(bg->top.file); bg->top.file = NULL; - if (bg->top.real_file) - Efree(bg->top.real_file); + Efree(bg->top.real_file); bg->top.real_file = NULL; BackgroundImagesFree(bg); @@ -249,8 +245,7 @@ BackgroundDestroy(Background * bg) BackgroundFilesRemove(bg); BackgroundPixmapFree(bg); - if (bg->name) - Efree(bg->name); + Efree(bg->name); Efree(bg); @@ -424,8 +419,7 @@ BackgroundModify(Background * bg, EColor * solid, const char *bgn, char tile, } else updated = 1; - if (bg->bg.file) - Efree(bg->bg.file); + Efree(bg->bg.file); bg->bg.file = (bgn[0]) ? Estrdup(bgn) : NULL; if ((int)tile != bg->bg_tile) updated = 1; @@ -453,8 +447,7 @@ BackgroundModify(Background * bg, EColor * solid, const char *bgn, char tile, } else updated = 1; - if (bg->top.file) - Efree(bg->top.file); + Efree(bg->top.file); bg->top.file = (top[0]) ? Estrdup(top) : NULL; if ((int)tkeep_aspect != bg->top.keep_aspect) updated = 1; @@ -1193,8 +1186,7 @@ BackgroundsConfigLoad(FILE * fs) } else { - if (name) - Efree(name); + Efree(name); name = Estrdup(s2); } break; @@ -1230,19 +1222,14 @@ BackgroundsConfigLoad(FILE * fs) &i3, &i4, &i5, &i6); if (!ignore) { - if (bg1) - Efree(bg1); + Efree(bg1); bg1 = Estrdup(s2); } else { - if (bg->bg.file) - Efree(bg->bg.file); - if (bg->top.file) - { - Efree(bg->top.file); - bg->top.file = NULL; - } + Efree(bg->bg.file); + Efree(bg->top.file); + bg->top.file = NULL; bg->bg.file = Estrdup(s2); bg->bg_tile = i1; bg->bg.keep_aspect = i2; @@ -1258,8 +1245,7 @@ BackgroundsConfigLoad(FILE * fs) &j4, &j5); if (!ignore) { - if (bg2) - Efree(bg2); + Efree(bg2); bg2 = Estrdup(s2); } else @@ -1280,12 +1266,9 @@ BackgroundsConfigLoad(FILE * fs) err = -1; done: - if (name) - Efree(name); - if (bg1) - Efree(bg1); - if (bg2) - Efree(bg2); + Efree(name); + Efree(bg1); + Efree(bg2); return err; } @@ -1614,8 +1597,7 @@ BG_DialogSetFileName(DItem * di) Esnprintf(s, sizeof(s), _("Background definition information:\nName: %s\nFile: %s\n"), BackgroundGetName(tmp_bg), (stmp) ? stmp : _("-NONE-")); - if (stmp) - Efree(stmp); + Efree(stmp); DialogItemSetText(di, s); } @@ -2389,8 +2371,7 @@ BackgroundSet1(const char *name, const char *params) } else if (!strcmp(type, "bg.file")) { - if (bg->bg.file) - Efree(bg->bg.file); + Efree(bg->bg.file); bg->bg.file = Estrdup(p); } else if (!strcmp(type, "bg.tile")) @@ -2419,8 +2400,7 @@ BackgroundSet1(const char *name, const char *params) } else if (!strcmp(type, "top.file")) { - if (bg->top.file) - Efree(bg->top.file); + Efree(bg->top.file); bg->top.file = Estrdup(p); } else if (!strcmp(type, "top.keep_aspect")) diff --git a/src/borders.c b/src/borders.c index 6f601b84..12454c59 100644 --- a/src/borders.c +++ b/src/borders.c @@ -477,8 +477,7 @@ EwinBorderDetach(EWin * ewin) if (ewin->bits[i].win) EDestroyWindow(ewin->bits[i].win); } - if (ewin->bits) - Efree(ewin->bits); + Efree(ewin->bits); ewin->bits = NULL; BorderDecRefcount(b); @@ -647,13 +646,9 @@ BorderDestroy(Border * b) ECursorFree(b->part[i].ec); } - if (b->num_winparts > 0) - Efree(b->part); - - if (b->name) - Efree(b->name); - if (b->group_border_name) - Efree(b->group_border_name); + Efree(b->part); + Efree(b->name); + Efree(b->group_border_name); ActionclassFree(b->aclass); } diff --git a/src/buttons.c b/src/buttons.c index 84d06e46..79aec4fb 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -192,9 +192,7 @@ ButtonDestroy(Button * b) ImageclassFree(b->iclass); ActionclassFree(b->aclass); TextclassFree(b->tclass); - - if (b->label) - Efree(b->label); + Efree(b->label); Efree(b); } diff --git a/src/cmclass.c b/src/cmclass.c index 4c353f7e..1240d415 100644 --- a/src/cmclass.c +++ b/src/cmclass.c @@ -309,20 +309,13 @@ ColorModifierConfigLoad(FILE * fs) err = -1; done: - if (name) - Efree(name); - if (rx) - Efree(rx); - if (ry) - Efree(ry); - if (gx) - Efree(gx); - if (gy) - Efree(gy); - if (bx) - Efree(bx); - if (by) - Efree(by); + Efree(name); + Efree(rx); + Efree(ry); + Efree(gx); + Efree(gy); + Efree(bx); + Efree(by); return err; } @@ -338,18 +331,12 @@ ModifyCMClass(char *name, int rnum, unsigned char *rpx, unsigned char *rpy, if (!cm) return; - if (cm->red.px) - Efree(cm->red.px); - if (cm->red.py) - Efree(cm->red.py); - if (cm->green.px) - Efree(cm->green.px); - if (cm->green.py) - Efree(cm->green.py); - if (cm->blue.px) - Efree(cm->blue.px); - if (cm->blue.py) - Efree(cm->blue.py); + Efree(cm->red.px); + Efree(cm->red.py); + Efree(cm->green.px); + Efree(cm->green.py); + Efree(cm->blue.px); + Efree(cm->blue.py); cm->red.px = NULL; cm->red.py = NULL; @@ -602,18 +589,12 @@ IPC_ColormodifierSet(const char *params) AddItem(cm, cm->name, 0, LIST_TYPE_COLORMODIFIER); } Efree(name); - if (rpx) - Efree(rpx); - if (rpy) - Efree(rpy); - if (gpx) - Efree(gpx); - if (gpy) - Efree(gpy); - if (bpx) - Efree(bpx); - if (bpy) - Efree(bpy); + Efree(rpx); + Efree(rpy); + Efree(gpx); + Efree(gpy); + Efree(bpx); + Efree(bpy); } static const IpcItem CmClassIpcArray[] = { diff --git a/src/comms.c b/src/comms.c index 5b201390..fa645d55 100644 --- a/src/comms.c +++ b/src/comms.c @@ -75,16 +75,12 @@ ClientDestroy(Client * c) ecore_list_node_remove(client_list, c); - if (c->name) - Efree(c->name); - if (c->msg) - Efree(c->msg); - if (c->clientname) - Efree(c->clientname); - if (c->version) - Efree(c->version); - if (c->info) - Efree(c->info); + Efree(c->name); + Efree(c->msg); + Efree(c->clientname); + Efree(c->version); + Efree(c->info); + Efree(c); } @@ -101,14 +97,12 @@ ClientConfigure(Client * c, const char *str) if (!strcmp(param, "clientname")) { - if (c->clientname) - Efree(c->clientname); + Efree(c->clientname); c->clientname = Estrdup(value); } else if (!strcmp(param, "version")) { - if (c->version) - Efree(c->version); + Efree(c->version); c->version = Estrdup(value); } else if (!strcmp(param, "author")) @@ -125,8 +119,7 @@ ClientConfigure(Client * c, const char *str) } else if (!strcmp(param, "info")) { - if (c->info) - Efree(c->info); + Efree(c->info); c->info = Estrdup(value); } else if (!strcmp(param, "pixmap")) diff --git a/src/config.c b/src/config.c index 06cf34f9..e1917675 100644 --- a/src/config.c +++ b/src/config.c @@ -253,12 +253,9 @@ ConfigFilePreparse(const char *path, const char *dest) def_shell, path, dest); system(execline); - if (def_user) - Efree(def_user); - if (def_shell) - Efree(def_shell); - if (def_home) - Efree(def_home); + Efree(def_user); + Efree(def_shell); + Efree(def_home); return exists(dest) ? 0 : 1; } diff --git a/src/container.c b/src/container.c index 396f70c6..7ebb5fb3 100644 --- a/src/container.c +++ b/src/container.c @@ -173,13 +173,11 @@ ContainerDestroy(Container * ct, int exiting) ct->ops->Exit(ct, exiting); - if (ct->name) - Efree(ct->name); + Efree(ct->name); EDestroyWindow(ct->win); - if (ct->objs) - Efree(ct->objs); + Efree(ct->objs); Efree(ct); @@ -1547,8 +1545,7 @@ _DlgFillContainer(Dialog * d, DItem * table, void *data) tmp_ib_cover_hide = ct->cover_hide; tmp_ib_autoresize_anchor = ct->auto_resize_anchor; tmp_ib_anim_mode = ct->anim_mode; - if (tmp_ib_name) - Efree(tmp_ib_name); + Efree(tmp_ib_name); tmp_ib_name = Estrdup(ct->name); DialogSetTitle(d, ct->dlg_title); diff --git a/src/cursors.c b/src/cursors.c index dd6abdb3..3b7fe69e 100644 --- a/src/cursors.c +++ b/src/cursors.c @@ -125,10 +125,9 @@ ECursorDestroy(ECursor * ec) ecore_list_node_remove(cursor_list, ec); - if (ec->name) - Efree(ec->name); - if (ec->file) - Efree(ec->file); + Efree(ec->name); + Efree(ec->file); + Efree(ec); } diff --git a/src/desktops.c b/src/desktops.c index 881a254e..8e533525 100644 --- a/src/desktops.c +++ b/src/desktops.c @@ -1440,8 +1440,7 @@ DeskRestack(Desk * dsk) XRestackWindows(disp, wl, tot); - if (wl) - Efree(wl); + Efree(wl); done: if (dsk->stack.update_client_list) diff --git a/src/dialog.c b/src/dialog.c index ebd3579e..1a8ebada 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -232,7 +232,8 @@ DialogBindKey(Dialog * d, const char *key, DialogCallbackFunc * func, int val, void DialogKeybindingsDestroy(Dialog * d) { - _EFREE(d->keybindings); + Efree(d->keybindings); + d->keybindings = NULL; d->num_bindings = 0; } @@ -267,10 +268,8 @@ DialogDestroy(Dialog * d) { ecore_list_node_remove(dialog_list, d); - if (d->name) - Efree(d->name); - if (d->title) - Efree(d->title); + Efree(d->name); + Efree(d->title); DialogKeybindingsDestroy(d); if (d->item) DialogItemDestroy(d->item, 0); @@ -298,8 +297,7 @@ DialogFind(const char *name) void DialogSetTitle(Dialog * d, const char *title) { - if (d->title) - Efree(d->title); + Efree(d->title); d->title = Estrdup(title); d->set_title = 1; } @@ -1439,10 +1437,8 @@ DialogRealizeItem(Dialog * d, DItem * di) r++; } } - if (col_size) - Efree(col_size); - if (row_size) - Efree(row_size); + Efree(col_size); + Efree(row_size); } } break; @@ -1799,8 +1795,7 @@ DialogItemsRealize(Dialog * d) void DialogItemSetText(DItem * di, const char *text) { - if (di->text) - Efree(di->text); + Efree(di->text); di->text = Estrdup(text); } @@ -1876,8 +1871,7 @@ DialogItemSeparatorSetOrientation(DItem * di, char horizontal) void DialogItemImageSetFile(DItem * di, const char *image) { - if (di->item.image.image) - Efree(di->item.image.image); + Efree(di->item.image.image); di->item.image.image = Estrdup(image); di->fill_h = 0; di->fill_v = 0; @@ -2001,9 +1995,7 @@ DialogItemTableEmpty(DItem * di) for (i = 0; i < di->item.table.num_items; i++) DialogItemDestroy(di->item.table.items[i], 1); - if (di->item.table.items) - Efree(di->item.table.items); - + Efree(di->item.table.items); di->item.table.items = NULL; di->item.table.num_items = 0; } @@ -2014,8 +2006,7 @@ DialogItemDestroy(DItem * di, int clean) if (di->type == DITEM_TABLE) DialogItemTableEmpty(di); - if (di->text) - Efree(di->text); + Efree(di->text); switch (di->type) { @@ -2027,8 +2018,7 @@ DialogItemDestroy(DItem * di, int clean) EDestroyWindow(di->item.check_button.check_win); break; case DITEM_IMAGE: - if (di->item.image.image) - Efree(di->item.image.image); + Efree(di->item.image.image); break; case DITEM_RADIOBUTTON: if (!clean) diff --git a/src/ecompmgr.c b/src/ecompmgr.c index ac7cfedf..b699fe20 100644 --- a/src/ecompmgr.c +++ b/src/ecompmgr.c @@ -1822,7 +1822,8 @@ ECompMgrWinDel(EObj * eo) REGION_DESTROY(cw->extents); REGION_DESTROY(cw->clip); - _EFREE(eo->cmhook); + Efree(eo->cmhook); + eo->cmhook = NULL; _ECM_SET_STACK_CHANGED(); } @@ -2392,8 +2393,7 @@ ECompMgrShadowsInit(int mode, int cleanup) OpacityFix(Conf_compmgr.shadows.sharp.opacity, 100); Mode_compmgr.opac_sharp = .01 * Conf_compmgr.shadows.sharp.opacity; - if (gaussianMap) - Efree(gaussianMap); + Efree(gaussianMap); gaussianMap = NULL; if (mode != ECM_SHADOWS_OFF) diff --git a/src/econfig.c b/src/econfig.c index 78f85075..adeb5065 100644 --- a/src/econfig.c +++ b/src/econfig.c @@ -412,8 +412,7 @@ CfgItemSetFromString(const CfgItem * ci, const char *str) *((float *)ci->ptr) = fval; break; case ITEM_TYPE_STRING: - if (*(char **)ci->ptr) - Efree(*(char **)ci->ptr); + Efree(*(char **)ci->ptr); if (*str == '\0') str = NULL; *((char **)ci->ptr) = Estrdup(str); diff --git a/src/eobj.c b/src/eobj.c index b53c4794..cc831ce7 100644 --- a/src/eobj.c +++ b/src/eobj.c @@ -246,12 +246,9 @@ EobjFini(EObj * eo) else EDestroyWindow(eo->win); - if (eo->icccm.wm_name) - Efree(eo->icccm.wm_name); - if (eo->icccm.wm_res_name) - Efree(eo->icccm.wm_res_name); - if (eo->icccm.wm_res_class) - Efree(eo->icccm.wm_res_class); + Efree(eo->icccm.wm_name); + Efree(eo->icccm.wm_res_name); + Efree(eo->icccm.wm_res_class); } void diff --git a/src/ewin-ops.c b/src/ewin-ops.c index dfeb0bfb..6b7b5568 100644 --- a/src/ewin-ops.c +++ b/src/ewin-ops.c @@ -419,8 +419,7 @@ doEwinMoveResize(EWin * ewin, Desk * dsk, int x, int y, int w, int h, int flags) EoGetY(lst[i]) + dy, 0, 0, flags & (MRF_DESK | MRF_MOVE | MRF_FLOAT | MRF_UNFLOAT)); - if (lst) - Efree(lst); + Efree(lst); } EwinDetermineArea(ewin); @@ -588,8 +587,7 @@ EwinIconify(EWin * ewin) if (lst && call_depth == 1) GNOME_SetClientList(); #endif - if (lst) - Efree(lst); + Efree(lst); EwinStateUpdate(ewin); HintsSetWindowState(ewin); @@ -663,8 +661,7 @@ EwinDeIconify1(EWin * ewin, int dx, int dy) if (lst && call_depth == 1) GNOME_SetClientList(); #endif - if (lst) - Efree(lst); + Efree(lst); EwinStateUpdate(ewin); HintsSetWindowState(ewin); @@ -1308,8 +1305,7 @@ EwinOpFullscreen(EWin * ewin, int source __UNUSED__, int on) EoSetLayer(lst[i], lst[i]->save_fs.layer + EoGetLayer(ewin) - ewin->save_fs.layer); } - if (lst) - Efree(lst); + Efree(lst); } EwinRaise(ewin); @@ -1334,8 +1330,7 @@ EwinOpFullscreen(EWin * ewin, int source __UNUSED__, int on) lst = EwinListTransients(ewin, &num, 0); for (i = 0; i < num; i++) EoSetLayer(lst[i], lst[i]->save_fs.layer); - if (lst) - Efree(lst); + Efree(lst); } EoSetLayer(ewin, ewin->save_fs.layer); @@ -1428,8 +1423,7 @@ EwinOpClose(EWin * ewin, int source __UNUSED__) ICCCM_Delete(gwins[i]); SoundPlay("SOUND_WINDOW_CLOSE"); } - if (gwins) - Efree(gwins); + Efree(gwins); } void @@ -1524,8 +1518,7 @@ EwinOpRaiseLower(EWin * ewin) EwinRaise(gwins[j]); } - if (gwins) - Efree(gwins); + Efree(gwins); } #endif @@ -1554,8 +1547,7 @@ EwinOpStick(EWin * ewin, int source __UNUSED__, int on) EwinStick(gwins[i]); } } - if (gwins) - Efree(gwins); + Efree(gwins); } void @@ -1636,8 +1628,7 @@ EwinOpIconify(EWin * ewin, int source __UNUSED__, int on) EwinIconify(gwins[i]); } } - if (gwins) - Efree(gwins); + Efree(gwins); } void @@ -1736,8 +1727,7 @@ EwinOpSetBorder(EWin * ewin, int source __UNUSED__, const char *name) } SnapshotEwinUpdate(gwins[i], SNAP_USE_BORDER); } - if (gwins) - Efree(gwins); + Efree(gwins); } void diff --git a/src/ewins.c b/src/ewins.c index d74c503c..057ca60b 100644 --- a/src/ewins.c +++ b/src/ewins.c @@ -392,8 +392,7 @@ EwinDestroy(EWin * ewin) if (lst[i]->icccm.transient_count < 0) /* Paranoia? */ lst[i]->icccm.transient_count = 0; } - if (lst) - Efree(lst); + Efree(lst); EwinCleanup(ewin); EobjListOrderDel(&ewin->o); @@ -402,26 +401,18 @@ EwinDestroy(EWin * ewin) HintsSetClientList(); - if (ewin->icccm.wm_icon_name) - Efree(ewin->icccm.wm_icon_name); - if (ewin->icccm.wm_role) - Efree(ewin->icccm.wm_role); - if (ewin->icccm.wm_command) - Efree(ewin->icccm.wm_command); - if (ewin->icccm.wm_machine) - Efree(ewin->icccm.wm_machine); - if (ewin->ewmh.wm_name) - Efree(ewin->ewmh.wm_name); - if (ewin->ewmh.wm_icon_name) - Efree(ewin->ewmh.wm_icon_name); - if (ewin->ewmh.wm_icon) - Efree(ewin->ewmh.wm_icon); - if (ewin->bits) - Efree(ewin->bits); - if (ewin->session_id) - Efree(ewin->session_id); + Efree(ewin->icccm.wm_icon_name); + Efree(ewin->icccm.wm_role); + Efree(ewin->icccm.wm_command); + Efree(ewin->icccm.wm_machine); + Efree(ewin->ewmh.wm_name); + Efree(ewin->ewmh.wm_icon_name); + Efree(ewin->ewmh.wm_icon); + Efree(ewin->bits); + Efree(ewin->session_id); FreePmapMask(&ewin->mini_pmm); GroupsEwinRemove(ewin); + Efree(ewin); } @@ -1385,8 +1376,7 @@ EwinRaise(EWin * ewin) lst = EwinListTransients(ewin, &num, 1); for (i = 0; i < num; i++) EwinRaise(lst[i]); - if (lst) - Efree(lst); + Efree(lst); if (call_depth == 1) { @@ -1421,8 +1411,7 @@ EwinLower(EWin * ewin) lst = EwinListTransientFor(ewin, &num); for (i = 0; i < num; i++) EwinLower(lst[i]); - if (lst) - Efree(lst); + Efree(lst); if (call_depth == 1) { diff --git a/src/ewmh.c b/src/ewmh.c index cc58242c..d23e64cd 100644 --- a/src/ewmh.c +++ b/src/ewmh.c @@ -612,11 +612,8 @@ EWMH_GetWindowIcons(EWin * ewin) unsigned int *val; int num; - if (ewin->ewmh.wm_icon) - { - Efree(ewin->ewmh.wm_icon); - ewin->ewmh.wm_icon = NULL; - } + Efree(ewin->ewmh.wm_icon); + ewin->ewmh.wm_icon = NULL; num = ecore_x_window_prop_card32_list_get(EwinGetClientXwin(ewin), ECORE_X_ATOM_NET_WM_ICON, &val); diff --git a/src/file.c b/src/file.c index 66049d10..50c2fe8a 100644 --- a/src/file.c +++ b/src/file.c @@ -316,8 +316,7 @@ path_test(const char *file, unsigned int test) if (file_test(s, test)) return s; } - if (s) - Efree(s); + Efree(s); return NULL; } diff --git a/src/fonts.c b/src/fonts.c index 7e61336c..9cf868e6 100644 --- a/src/fonts.c +++ b/src/fonts.c @@ -38,8 +38,9 @@ _FontAliasDestroy(void *data) if (!fa) return; - _EFREE(fa->name); - _EFREE(fa->font); + Efree(fa->name); + Efree(fa->font); + Efree(fa); } diff --git a/src/fx.c b/src/fx.c index 6ef0156f..fc4241b8 100644 --- a/src/fx.c +++ b/src/fx.c @@ -671,8 +671,7 @@ FX_ImageSpinner_Quit(void) { RemoveTimerEvent("FX_IMAGESPINNER_TIMEOUT"); XClearArea(disp, fx_imagespinner_win, 0, 0, VRoot.w, VRoot.h, False); - if (fx_imagespinner_params) - Efree(fx_imagespinner_params); + Efree(fx_imagespinner_params); fx_imagespinner_params = NULL; fx_imagespinner_win = None; } diff --git a/src/gnome.c b/src/gnome.c index 793bbdc6..9e5c57bd 100644 --- a/src/gnome.c +++ b/src/gnome.c @@ -644,8 +644,7 @@ GNOME_SetDeskNames(void) ecore_x_window_prop_string_list_set(VRoot.xwin, atom_set, names, n_desks); for (i = 0; i < n_desks; i++) - if (names[i]) - Efree(names[i]); + Efree(names[i]); Efree(names); } @@ -674,8 +673,7 @@ GNOME_SetClientList(void) } } ecore_x_window_prop_card32_set(VRoot.xwin, atom_set, wl, j); - if (wl) - Efree(wl); + Efree(wl); } static void diff --git a/src/groups.c b/src/groups.c index eb0935de..b65e9fce 100644 --- a/src/groups.c +++ b/src/groups.c @@ -102,8 +102,8 @@ GroupDestroy(Group * g) if (g == Mode_groups.current) Mode_groups.current = NULL; - if (g->members) - Efree(g->members); + Efree(g->members); + Efree(g); } diff --git a/src/iclass.c b/src/iclass.c index 41e52f36..c3eafa73 100644 --- a/src/iclass.c +++ b/src/iclass.c @@ -224,38 +224,34 @@ ImagestateCreate(const char *file) } static void -FreeImageState(ImageState * i) +ImagestateDestroy(ImageState * is) { + if (!is) + return; - Efree(i->im_file); - Efree(i->real_file); + Efree(is->im_file); + Efree(is->real_file); - if (i->im) - { - EImageFree(i->im); - i->im = NULL; - } + if (is->im) + EImageFree(is->im); - if (i->border) - Efree(i->border); + Efree(is->border); #if ENABLE_COLOR_MODIFIERS - if (i->colmod) - i->colmod->ref_count--; + if (is->colmod) + is->colmod->ref_count--; #endif + + Efree(is); } static void FreeImageStateArray(ImageStateArray * isa) { - FreeImageState(isa->normal); - Efree(isa->normal); - FreeImageState(isa->hilited); - Efree(isa->hilited); - FreeImageState(isa->clicked); - Efree(isa->clicked); - FreeImageState(isa->disabled); - Efree(isa->disabled); + ImagestateDestroy(isa->normal); + ImagestateDestroy(isa->hilited); + ImagestateDestroy(isa->clicked); + ImagestateDestroy(isa->disabled); } static void @@ -362,8 +358,7 @@ ImageclassDestroy(ImageClass * ic) ecore_list_node_remove(iclass_list, ic); - if (ic->name) - Efree(ic->name); + Efree(ic->name); FreeImageStateArray(&(ic->norm)); FreeImageStateArray(&(ic->active)); @@ -374,6 +369,8 @@ ImageclassDestroy(ImageClass * ic) if (ic->colmod) ic->colmod->ref_count--; #endif + + Efree(ic); } ImageClass * diff --git a/src/iconify.c b/src/iconify.c index 24c48c23..275b9a9d 100644 --- a/src/iconify.c +++ b/src/iconify.c @@ -397,8 +397,7 @@ SelectIconboxForEwin(EWin * ewin) ib_sel = ct; } } - if (lst) - Efree(lst); + Efree(lst); } return ib_sel; @@ -435,8 +434,7 @@ IconboxesUpdateEwinIcon(EWin * ewin, int icon_mode) ct = lst[i]; IconboxUpdateEwinIcon(ct, ewin, icon_mode); } - if (lst) - Efree(lst); + Efree(lst); } static void diff --git a/src/lang.c b/src/lang.c index 1fe870a6..a9afb497 100644 --- a/src/lang.c +++ b/src/lang.c @@ -137,8 +137,7 @@ EstrInt2EncFree(const char *str, int want_utf8) if (Mode.locale.utf8_int == want_utf8) return; - if (str) - Efree((char *)str); + Efree((char *)str); #else str = NULL; want_utf8 = 0; diff --git a/src/main.c b/src/main.c index dfed67c5..6948365b 100644 --- a/src/main.c +++ b/src/main.c @@ -502,8 +502,7 @@ EDirRoot(void) static void EConfNameSet(const char *name) { - if (Mode.conf.name) - Efree(Mode.conf.name); + Efree(Mode.conf.name); Mode.conf.name = Estrdup(name); Esetenv("ECONFNAME", Mode.conf.name); } @@ -513,8 +512,7 @@ EDirUserSet(const char *dir) { if (!strcmp(dir, EDirUser())) return; - if (Mode.conf.dir) - Efree(Mode.conf.dir); + Efree(Mode.conf.dir); Mode.conf.dir = Estrdup(dir); } @@ -523,8 +521,7 @@ EDirUserCacheSet(const char *dir) { if (!strcmp(dir, EDirUser())) return; - if (Mode.conf.cache_dir) - Efree(Mode.conf.cache_dir); + Efree(Mode.conf.cache_dir); Mode.conf.cache_dir = Estrdup(dir); } diff --git a/src/memory.c b/src/memory.c index 5388fc2a..afddef91 100644 --- a/src/memory.c +++ b/src/memory.c @@ -130,8 +130,7 @@ StrlistFree(char **lst, int num) if (!lst) return; while (num--) - if (lst[num]) - Efree(lst[num]); + Efree(lst[num]); Efree(lst); } diff --git a/src/menus-misc.c b/src/menus-misc.c index 344ff196..e9d897a1 100644 --- a/src/menus-misc.c +++ b/src/menus-misc.c @@ -510,8 +510,7 @@ MenuCreateFromGnome(const char *name, Menu * parent, MenuStyle * ms, } if (iname) { - if (en_name) - Efree(en_name); + Efree(en_name); } else { @@ -532,12 +531,9 @@ MenuCreateFromGnome(const char *name, Menu * parent, MenuStyle * ms, MenuAddItem(m, mi); } } - if (iname) - Efree(iname); - if (exec) - Efree(exec); - if (texec) - Efree(texec); + Efree(iname); + Efree(exec); + Efree(texec); } } } @@ -622,8 +618,7 @@ MenuCreateFromBorders(const char *name, MenuStyle * ms) MenuAddItem(m, mi); } } - if (lst) - Efree(lst); + Efree(lst); return m; } diff --git a/src/menus.c b/src/menus.c index e57a743f..1af1a9da 100644 --- a/src/menus.c +++ b/src/menus.c @@ -384,8 +384,7 @@ MenuShow(Menu * m, char noshow) static void MenuStyleSetName(MenuStyle * ms, const char *name) { - if (ms->name) - Efree(ms->name); + Efree(ms->name); ms->name = Estrdup(name); } @@ -486,8 +485,7 @@ MenuSetIconSize(Menu * m, int size) void MenuSetData(Menu * m, char *data) { - if (m->data) - Efree(m->data); + Efree(m->data); m->data = data; } @@ -578,14 +576,10 @@ MenuDestroy(Menu * m) if (m->win) EDestroyWindow(m->win); - if (m->name) - Efree(m->name); - if (m->alias) - Efree(m->alias); - if (m->title) - Efree(m->title); - if (m->data) - Efree(m->data); + Efree(m->name); + Efree(m->alias); + Efree(m->title); + Efree(m->data); Efree(m); } @@ -612,20 +606,16 @@ MenuEmpty(Menu * m, int destroying) mi->child->ref_count--; MenuDestroy(mi->child); } - if (mi->text) - Efree(mi->text); - if (mi->params) - Efree(mi->params); + Efree(mi->text); + Efree(mi->params); for (j = 0; j < 3; j++) FreePmapMask(&(mi->pmm[j])); if (!destroying && mi->win) EDestroyWindow(mi->win); ImageclassFree(mi->icon_iclass); - if (mi) - Efree(mi); + Efree(mi); } - if (m->items) - Efree(m->items); + Efree(m->items); m->items = NULL; m->num = 0; m->sel_item = NULL; diff --git a/src/moveresize.c b/src/moveresize.c index 7c4a5773..2dc9f46e 100644 --- a/src/moveresize.c +++ b/src/moveresize.c @@ -227,8 +227,7 @@ ActionMoveSuspend(void) DrawEwinShape(ewin, Mode_mr.mode, ewin->shape_x, ewin->shape_y, ewin->client.w, ewin->client.h, 3, i); } - if (lst) - Efree(lst); + Efree(lst); EUngrabServer(); } @@ -279,8 +278,7 @@ ActionMoveResume(void) DrawEwinShape(ewin, Mode_mr.mode, x, y, ewin->client.w, ewin->client.h, fl, i); } - if (lst) - Efree(lst); + Efree(lst); return 0; } diff --git a/src/pager.c b/src/pager.c index 6204d506..0e2a453c 100644 --- a/src/pager.c +++ b/src/pager.c @@ -160,8 +160,7 @@ PagerDestroy(Pager * p) ecore_list_node_remove(pager_list, p); PagerScanCancel(p); - if (p->name) - Efree(p->name); + Efree(p->name); EDestroyWindow(p->win); PagerHiwinHide(); if (p->bgpmap != None) @@ -1378,8 +1377,7 @@ EwinGroupMove(EWin * ewin, Desk * dsk, int x, int y) EwinOpMove(gwins[i], OPSRC_USER, EoGetX(gwins[i]) + dx, EoGetY(gwins[i]) + dy); } - if (gwins) - Efree(gwins); + Efree(gwins); } static void @@ -1524,8 +1522,7 @@ PagerHiwinHandleMouseUp(Pager * p, int px, int py, int button) EwinIconify(gwins[i]); } } - if (gwins) - Efree(gwins); + Efree(gwins); } else if (ewin2 && ewin2->props.vroot) { diff --git a/src/session.c b/src/session.c index 877531f9..5b85c227 100644 --- a/src/session.c +++ b/src/session.c @@ -248,8 +248,7 @@ set_save_props(SmcConn smc_conn, int master_flag) props[n++] = &priorityProp; SmcSetProperties(smc_conn, n, props); - if (user) - Efree(user); + Efree(user); } /* This function is usually exclusively devoted to saving data. @@ -386,8 +385,7 @@ ice_init(void) SmcSaveCompleteProcMask | SmcShutdownCancelledProcMask, &callbacks, client_id, &sm_client_id, 4096, error_string_ret); - if (client_id) - Efree(client_id); + Efree(client_id); if (error_string_ret[0]) Eprintf("While connecting to session manager: %s.", error_string_ret); diff --git a/src/snaps.c b/src/snaps.c index eaa2d576..4fae238e 100644 --- a/src/snaps.c +++ b/src/snaps.c @@ -102,22 +102,15 @@ SnapshotDestroy(Snapshot * sn) if (sn->used) sn->used->snap = NULL; - if (sn->name) - Efree(sn->name); - if (sn->win_title) - Efree(sn->win_title); - if (sn->win_name) - Efree(sn->win_name); - if (sn->win_class) - Efree(sn->win_class); - if (sn->win_role) - Efree(sn->win_role); - if (sn->border_name) - Efree(sn->border_name); - if (sn->cmd) - Efree(sn->cmd); - if (sn->groups) - Efree(sn->groups); + Efree(sn->name); + Efree(sn->win_title); + Efree(sn->win_name); + Efree(sn->win_class); + Efree(sn->win_role); + Efree(sn->border_name); + Efree(sn->cmd); + Efree(sn->groups); + Efree(sn); } @@ -311,8 +304,7 @@ SnapshotEwinGet(EWin * ewin, unsigned int match_flags) static void SnapEwinBorder(Snapshot * sn, const EWin * ewin) { - if (sn->border_name) - Efree(sn->border_name); + Efree(sn->border_name); sn->border_name = NULL; if (ewin->previous_border) sn->border_name = Estrdup(BorderGetName(ewin->previous_border)); @@ -389,8 +381,7 @@ SnapEwinCmd(Snapshot * sn, const EWin * ewin) strcmp(ewin->icccm.wm_machine, Mode.wm.machine_name)) return; - if (sn->cmd) - Efree(sn->cmd); + Efree(sn->cmd); sn->cmd = Estrdup(ewin->icccm.wm_command); } @@ -406,8 +397,8 @@ SnapEwinGroups(Snapshot * sn, const EWin * ewin, char onoff) if (!ewin->groups) { - if (sn->groups) - Efree(sn->groups); + Efree(sn->groups); + sn->groups = NULL; sn->num_groups = 0; return; } @@ -427,9 +418,7 @@ SnapEwinGroups(Snapshot * sn, const EWin * ewin, char onoff) sn = SnapshotEwinGet(gwins[i], SNAP_MATCH_DEFAULT); if (sn) { - if (sn->groups) - Efree(sn->groups); - + Efree(sn->groups); sn->groups = EMALLOC(int, num_groups); sn->num_groups = num_groups; @@ -447,8 +436,8 @@ SnapEwinGroups(Snapshot * sn, const EWin * ewin, char onoff) sn = gwins[i]->snap; if (sn) { - if (sn->groups) - Efree(sn->groups); + Efree(sn->groups); + sn->groups = NULL; sn->num_groups = 0; } } diff --git a/src/sound.c b/src/sound.c index 6963e355..0978febd 100644 --- a/src/sound.c +++ b/src/sound.c @@ -96,10 +96,9 @@ SclassDestroy(SoundClass * sclass) ecore_list_node_remove(sound_list, sclass); _SclassSampleDestroy(sclass, NULL); - if (sclass->name) - Efree(sclass->name); - if (sclass->file) - Efree(sclass->file); + Efree(sclass->name); + Efree(sclass->file); + Efree(sclass); } diff --git a/src/tclass.c b/src/tclass.c index 3a3a16f7..0fef61e2 100644 --- a/src/tclass.c +++ b/src/tclass.c @@ -69,10 +69,13 @@ TextstateCreate(const char *font) static void TextStateDestroy(TextState * ts) { - if (ts->fontname) - Efree(ts->fontname); + if (!ts) + return; + + Efree(ts->fontname); if (ts->ops) ts->ops->Destroy(ts); + Efree(ts); } @@ -104,40 +107,24 @@ TextclassDestroy(TextClass * tc) tc->ref_count); return; } - if (tc->name) - Efree(tc->name); - if (tc->norm.normal) - TextStateDestroy(tc->norm.normal); - if (tc->norm.hilited) - TextStateDestroy(tc->norm.hilited); - if (tc->norm.clicked) - TextStateDestroy(tc->norm.clicked); - if (tc->norm.disabled) - TextStateDestroy(tc->norm.disabled); - if (tc->active.normal) - TextStateDestroy(tc->active.normal); - if (tc->active.hilited) - TextStateDestroy(tc->active.hilited); - if (tc->active.clicked) - TextStateDestroy(tc->active.clicked); - if (tc->active.disabled) - TextStateDestroy(tc->active.disabled); - if (tc->sticky.normal) - TextStateDestroy(tc->sticky.normal); - if (tc->sticky.hilited) - TextStateDestroy(tc->sticky.hilited); - if (tc->sticky.clicked) - TextStateDestroy(tc->sticky.clicked); - if (tc->sticky.disabled) - TextStateDestroy(tc->sticky.disabled); - if (tc->sticky_active.normal) - TextStateDestroy(tc->sticky_active.normal); - if (tc->sticky_active.hilited) - TextStateDestroy(tc->sticky_active.hilited); - if (tc->sticky_active.clicked) - TextStateDestroy(tc->sticky_active.clicked); - if (tc->sticky_active.disabled) - TextStateDestroy(tc->sticky_active.disabled); + Efree(tc->name); + TextStateDestroy(tc->norm.normal); + TextStateDestroy(tc->norm.hilited); + TextStateDestroy(tc->norm.clicked); + TextStateDestroy(tc->norm.disabled); + TextStateDestroy(tc->active.normal); + TextStateDestroy(tc->active.hilited); + TextStateDestroy(tc->active.clicked); + TextStateDestroy(tc->active.disabled); + TextStateDestroy(tc->sticky.normal); + TextStateDestroy(tc->sticky.hilited); + TextStateDestroy(tc->sticky.clicked); + TextStateDestroy(tc->sticky.disabled); + TextStateDestroy(tc->sticky_active.normal); + TextStateDestroy(tc->sticky_active.hilited); + TextStateDestroy(tc->sticky_active.clicked); + TextStateDestroy(tc->sticky_active.disabled); + Efree(tc); } @@ -178,7 +165,6 @@ TextclassSetJustification(TextClass * tc, int just) static void TextclassPopulate(TextClass * tclass) { - if (!tclass) return; diff --git a/src/text.c b/src/text.c index 30880584..13ee72a9 100644 --- a/src/text.c +++ b/src/text.c @@ -391,8 +391,7 @@ TextstateTextFitMB(TextState * ts, char **ptext, int *pw, int textwidth_limit) Efree(text); *ptext = new_line; done: - if (wc_line) - Efree(wc_line); + Efree(wc_line); EwcClose(); } diff --git a/src/theme.c b/src/theme.c index aa93338a..8f99f76e 100644 --- a/src/theme.c +++ b/src/theme.c @@ -106,10 +106,8 @@ append_merge_dir(char *dir, char ***list, int *count) tmp2 = fileof(str[i]); if ((tmp != NULL) && (tmp2 != NULL) && (!strcmp(tmp, tmp2))) already = 1; - if (tmp) - Efree(tmp); - if (tmp2) - Efree(tmp2); + Efree(tmp); + Efree(tmp2); } if (already) @@ -421,12 +419,10 @@ ThemePathFind(void) EDirRoot(), EDirUser()); } - if (Conf.theme.name) - Efree(Conf.theme.name); + Efree(Conf.theme.name); Conf.theme.name = (theme) ? fullfileof(theme) : NULL; - if (Mode.theme.path) - Efree(Mode.theme.path); + Efree(Mode.theme.path); Mode.theme.path = theme; } diff --git a/src/timers.c b/src/timers.c index 2bedf511..6b4646b2 100644 --- a/src/timers.c +++ b/src/timers.c @@ -122,8 +122,7 @@ TimersRun(double tt) qe->func(qe->runtime_val, qe->runtime_data); /* free the timer */ - if (qe->name) - Efree(qe->name); + Efree(qe->name); Efree(qe); } @@ -164,10 +163,8 @@ RemoveTimerEvent(const char *name) else q_first = qe->next; /* free it */ - if (qe->name) - Efree(qe->name); - if (qe) - Efree(qe); + Efree(qe->name); + Efree(qe); /* done */ return 1; } @@ -303,8 +300,7 @@ AnimatorDel(Animator * an) #endif ecore_list_node_remove(animator_list, an); - if (an->name) - Efree(an->name); + Efree(an->name); Efree(an); if (ecore_list_count(animator_list) == 0) diff --git a/src/tooltips.c b/src/tooltips.c index 1e51d0fd..c3c839e8 100644 --- a/src/tooltips.c +++ b/src/tooltips.c @@ -661,8 +661,7 @@ TooltipShow(ToolTip * tt, const char *text, ActionClass * ac, int x, int y) } } - if (heights) - Efree(heights); + Efree(heights); } void diff --git a/src/util.h b/src/util.h index fd756995..2156d568 100644 --- a/src/util.h +++ b/src/util.h @@ -56,8 +56,12 @@ #include #define Ecalloc calloc #define Emalloc malloc -#define Efree free #define Erealloc realloc +#if HAVE_FREE_NULL_BUG +#define Efree(p) if (p) free(p) +#else +#define Efree free +#endif #define ECALLOC(type, num) (type*)Ecalloc(num, sizeof(type)) #define EMALLOC(type, num) (type*)Emalloc((num)*sizeof(type)) diff --git a/src/warp.c b/src/warp.c index 0fb31a42..0aefaa64 100644 --- a/src/warp.c +++ b/src/warp.c @@ -281,8 +281,7 @@ WarpFocusHide(void) if (fw && EoIsShown(fw)) WarpFocusWinHide(fw); - if (warplist) - Efree(warplist); + Efree(warplist); warplist = NULL; warplist_num = 0; } diff --git a/src/windowmatch.c b/src/windowmatch.c index 943c8c08..a485459f 100644 --- a/src/windowmatch.c +++ b/src/windowmatch.c @@ -123,12 +123,9 @@ WindowMatchDestroy(WindowMatch * wm) ecore_list_node_remove(wm_list, wm); - if (wm->name) - Efree(wm->name); - if (wm->value) - Efree(wm->value); - if (wm->args) - Efree(wm->args); + Efree(wm->name); + Efree(wm->value); + Efree(wm->args); Efree(wm); } @@ -659,7 +656,7 @@ WindowMatchEwinOpsAction(EWin * ewin, int op, const char *args) return; case EWIN_OP_TITLE: - _EFREE(EwinGetIcccmName(ewin)); + Efree(EwinGetIcccmName(ewin)); EwinGetIcccmName(ewin) = Estrdup(args); break; diff --git a/src/x.c b/src/x.c index b03dd52a..0131696f 100644 --- a/src/x.c +++ b/src/x.c @@ -128,8 +128,7 @@ EXidDestroy(Win win) #endif if (win->rects) XFree(win->rects); - if (win->cbl.lst) - Efree(win->cbl.lst); + Efree(win->cbl.lst); Efree(win); } @@ -1499,8 +1498,7 @@ EShapePropagate(Win win) return win->num_rect; bail_out: - if (rects) - Efree(rects); + Efree(rects); EShapeCombineMask(win, ShapeBounding, 0, 0, None, ShapeSet); return 0; }