Assume free(0) is ok (if not HAVE_FREE_NULL_BUG will have to be defined).

SVN revision: 33818
This commit is contained in:
Kim Woelders 2008-02-23 12:09:38 +00:00
parent 8380235420
commit 0a05aafc82
52 changed files with 285 additions and 487 deletions

View File

@ -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;

View File

@ -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))

View File

@ -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;
}

View File

@ -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

View File

@ -91,8 +91,7 @@ TextStateLoadFont(TextState * ts)
ts->height = as + ds;
}
}
if (s2)
free(s2);
Efree(s2);
if (ts->efont)
return;
}

View File

@ -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))

View File

@ -190,7 +190,6 @@ ClientDestroy(Client * c)
if (!c)
return;
if (c->msg)
Efree(c->msg);
Efree(c->msg);
Efree(c);
}

View File

@ -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;
}

View File

@ -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

View File

@ -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;

View File

@ -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"))

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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[] = {

View File

@ -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"))

View File

@ -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;
}

View File

@ -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);

View File

@ -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);
}

View File

@ -1440,8 +1440,7 @@ DeskRestack(Desk * dsk)
XRestackWindows(disp, wl, tot);
if (wl)
Efree(wl);
Efree(wl);
done:
if (dsk->stack.update_client_list)

View File

@ -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)

View File

@ -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)

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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)
{

View File

@ -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);

View File

@ -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;
}

View File

@ -38,8 +38,9 @@ _FontAliasDestroy(void *data)
if (!fa)
return;
_EFREE(fa->name);
_EFREE(fa->font);
Efree(fa->name);
Efree(fa->font);
Efree(fa);
}

View File

@ -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;
}

View File

@ -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

View File

@ -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);
}

View File

@ -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 *

View File

@ -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

View File

@ -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;

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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)
{

View File

@ -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);

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -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;

View File

@ -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();
}

View File

@ -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;
}

View File

@ -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)

View File

@ -661,8 +661,7 @@ TooltipShow(ToolTip * tt, const char *text, ActionClass * ac, int x, int y)
}
}
if (heights)
Efree(heights);
Efree(heights);
}
void

View File

@ -56,8 +56,12 @@
#include <stdlib.h>
#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))

View File

@ -281,8 +281,7 @@ WarpFocusHide(void)
if (fw && EoIsShown(fw))
WarpFocusWinHide(fw);
if (warplist)
Efree(warplist);
Efree(warplist);
warplist = NULL;
warplist_num = 0;
}

View File

@ -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;

View File

@ -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;
}