kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16.git/commit/?id=22b5e58dcd486210b2deb1c076a95a9488f89542

commit 22b5e58dcd486210b2deb1c076a95a9488f89542
Author: Kim Woelders <[email protected]>
Date:   Fri Feb 16 17:12:34 2018 +0100

    Refactor/rename/use _EFREE type macros
---
 src/aclass.c      |  9 ++++-----
 src/backgrounds.c | 34 +++++++++++-----------------------
 src/borders.c     |  3 +--
 src/buttons.c     |  2 +-
 src/comms.c       |  9 +++------
 src/config.c      |  6 ++----
 src/container.c   |  3 +--
 src/cursors.c     |  2 +-
 src/dialog.c      | 15 +++++----------
 src/draw.c        |  3 +--
 src/ecompmgr.c    |  6 ++----
 src/eobj.c        |  3 +--
 src/events.c      |  3 +--
 src/ewins.c       |  8 ++++----
 src/ewmh.c        |  7 +++----
 src/groups.c      |  6 ++----
 src/icccm.c       | 14 +++++++-------
 src/iclass.c      |  6 ++----
 src/ipc.c         |  3 +--
 src/lang.c        |  2 +-
 src/main.c        |  9 +++------
 src/menus.c       | 36 ++++++++++++++++--------------------
 src/pager.c       |  4 ++--
 src/progress.c    |  2 +-
 src/session.c     |  2 +-
 src/snaps.c       | 18 ++++++------------
 src/sound.c       |  2 +-
 src/sound_esd.c   |  6 +++---
 src/sound_load.c  |  4 ++--
 src/sound_pa.c    |  6 +++---
 src/stacking.c    |  3 +--
 src/theme.c       |  7 +++----
 src/util.h        |  5 +++--
 src/warp.c        |  3 +--
 src/windowmatch.c |  3 +--
 src/x.c           |  3 +--
 36 files changed, 102 insertions(+), 155 deletions(-)

diff --git a/src/aclass.c b/src/aclass.c
index 486e4846..288858e0 100644
--- a/src/aclass.c
+++ b/src/aclass.c
@@ -207,8 +207,8 @@ ActionclassEmpty(ActionClass * ac)
    for (i = 0; i < ac->num; i++)
       ActionDestroy(ac->actions[i]);
    ac->num = 0;
-   _EFREE(ac->actions);
-   _EFREE(ac->tooltipstring);
+   EFREE_NULL(ac->actions);
+   EFREE_NULL(ac->tooltipstring);
 }
 
 static void
@@ -464,8 +464,7 @@ 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);
-                 action_tooltipstring = NULL;
+                 EFREE_NULL(action_tooltipstring);
                  key[0] = '\0';
                  if (global)
                     GrabActionKey(aa);
@@ -887,7 +886,7 @@ BindingsSave(void)
 void
 ActionclassSetTooltipString(ActionClass * ac, const char *tts)
 {
-   _EFDUP(ac->tooltipstring, tts);
+   EFREE_DUP(ac->tooltipstring, tts);
 }
 
 ActionClass        *
diff --git a/src/backgrounds.c b/src/backgrounds.c
index 5a3c1554..110fa731 100644
--- a/src/backgrounds.c
+++ b/src/backgrounds.c
@@ -83,8 +83,7 @@ _BackgroundGetFile(char **ptr)
    path = ThemeFileFind(path, FILE_TYPE_BACKGROUND);
    if (!path)
       goto done;
-   Efree(*ptr);
-   *ptr = path;
+   EFREE_SET(*ptr, path);
  done:
    return path;
 }
@@ -236,11 +235,8 @@ BackgroundImagesKeep(Background * bg, int onoff)
 static void
 BackgroundFilesRemove(Background * bg)
 {
-   Efree(bg->bg.file);
-   bg->bg.file = NULL;
-
-   Efree(bg->top.file);
-   bg->top.file = NULL;
+   EFREE_NULL(bg->bg.file);
+   EFREE_NULL(bg->top.file);
 
    BackgroundImagesFree(bg);
 
@@ -435,8 +431,7 @@ BackgroundModify(Background * bg, unsigned int solid, const 
char *bgn,
      }
    else
       updated = 1;
-   Efree(bg->bg.file);
-   bg->bg.file = (bgn && bgn[0]) ? Estrdup(bgn) : NULL;
+   EFREE_SET(bg->bg.file, (bgn && bgn[0]) ? Estrdup(bgn) : NULL);
    if ((int)tile != bg->bg_tile)
       updated = 1;
    if ((int)keep_aspect != bg->bg.keep_aspect)
@@ -463,8 +458,7 @@ BackgroundModify(Background * bg, unsigned int solid, const 
char *bgn,
      }
    else
       updated = 1;
-   Efree(bg->top.file);
-   bg->top.file = (top && top[0]) ? Estrdup(top) : NULL;
+   EFREE_SET(bg->top.file, (top && top[0]) ? Estrdup(top) : NULL);
    if ((int)tkeep_aspect != bg->top.keep_aspect)
       updated = 1;
    if (txjust != bg->top.xjust)
@@ -1163,8 +1157,7 @@ BackgroundsConfigLoad(FILE * fs)
             break;
 
          case BG_BG_FILE:
-            Efree(bg1);
-            bg1 = Estrdup(p2);
+            EFREE_DUP(bg1, p2);
             break;
 
          case BG_BG_PARAM:
@@ -1174,14 +1167,12 @@ BackgroundsConfigLoad(FILE * fs)
 #if 1                          /* Obsolete - backward compatibility */
          case BG_BG1:
             sscanf(p3, "%d %d %d %d %d %d", &i1, &i2, &i3, &i4, &i5, &i6);
-            Efree(bg1);
-            bg1 = Estrdup(s2);
+            EFREE_DUP(bg1, s2);
             break;
 #endif
 
          case BG_TOP_FILE:
-            Efree(bg2);
-            bg2 = Estrdup(p2);
+            EFREE_DUP(bg2, p2);
             break;
 
          case BG_TOP_PARAM:
@@ -1191,8 +1182,7 @@ BackgroundsConfigLoad(FILE * fs)
 #if 1                          /* Obsolete - backward compatibility */
          case BG_BG2:
             sscanf(p3, "%d %d %d %d %d", &j1, &j2, &j3, &j4, &j5);
-            Efree(bg2);
-            bg2 = Estrdup(s2);
+            EFREE_DUP(bg2, s2);
             break;
 #endif
 
@@ -2278,8 +2268,7 @@ BackgroundSet1(const char *name, const char *params)
      }
    else if (!strcmp(type, "bg.file"))
      {
-       Efree(bg->bg.file);
-       bg->bg.file = Estrdup(p);
+       EFREE_DUP(bg->bg.file, p);
      }
    else if (!strcmp(type, "bg.tile"))
      {
@@ -2307,8 +2296,7 @@ BackgroundSet1(const char *name, const char *params)
      }
    else if (!strcmp(type, "top.file"))
      {
-       Efree(bg->top.file);
-       bg->top.file = Estrdup(p);
+       EFREE_DUP(bg->top.file, p);
      }
    else if (!strcmp(type, "top.keep_aspect"))
      {
diff --git a/src/borders.c b/src/borders.c
index edd08da0..2afb533f 100644
--- a/src/borders.c
+++ b/src/borders.c
@@ -532,8 +532,7 @@ EwinBorderDetach(EWin * ewin)
        if (ewin->bits[i].win)
           EDestroyWindow(ewin->bits[i].win);
      }
-   Efree(ewin->bits);
-   ewin->bits = NULL;
+   EFREE_NULL(ewin->bits);
    BorderDecRefcount(b);
 
    ewin->border = NULL;
diff --git a/src/buttons.c b/src/buttons.c
index 20a35fe8..cbd490bd 100644
--- a/src/buttons.c
+++ b/src/buttons.c
@@ -709,7 +709,7 @@ ButtonsConfigLoad(FILE * fs)
             else if (pbt)
               {
                  if (label[0])
-                    _EFDUP(pbt->label, label);
+                    EFREE_DUP(pbt->label, label);
                  EoSetLayer(pbt, ontop);
                  EoSetSticky(pbt, sticky);
                  ButtonMoveToDesktop(pbt, DeskGet(desk));
diff --git a/src/comms.c b/src/comms.c
index d533cc00..705ef801 100644
--- a/src/comms.c
+++ b/src/comms.c
@@ -99,13 +99,11 @@ ClientConfigure(Client * c, const char *str)
 
    if (!strcmp(param, "clientname"))
      {
-       Efree(c->clientname);
-       c->clientname = Estrdup(value);
+       EFREE_DUP(c->clientname, value);
      }
    else if (!strcmp(param, "version"))
      {
-       Efree(c->version);
-       c->version = Estrdup(value);
+       EFREE_DUP(c->version, value);
      }
    else if (!strcmp(param, "author"))
      {
@@ -121,8 +119,7 @@ ClientConfigure(Client * c, const char *str)
      }
    else if (!strcmp(param, "info"))
      {
-       Efree(c->info);
-       c->info = Estrdup(value);
+       EFREE_DUP(c->info, value);
      }
    else if (!strcmp(param, "pixmap"))
      {
diff --git a/src/config.c b/src/config.c
index a0c28da5..4745148c 100644
--- a/src/config.c
+++ b/src/config.c
@@ -151,8 +151,7 @@ GetLine(char *s, int size, FILE * f)
    if (!si)
      {
        /* EOF */
-       Efree(buffer);
-       buffer = NULL;
+       EFREE_NULL(buffer);
        if (so == s)
           return NULL;
      }
@@ -537,8 +536,7 @@ ConfigFileFind(const char *name, const char *themepath, int 
pp)
    err = ConfigFilePreparse(fullname, ppfile, themepath);
    if (err)
      {
-       Efree(ppfile);
-       ppfile = NULL;
+       EFREE_NULL(ppfile);
      }
 
  done:
diff --git a/src/container.c b/src/container.c
index cabc68bc..45388ca5 100644
--- a/src/container.c
+++ b/src/container.c
@@ -352,8 +352,7 @@ ContainerObjectDel(Container * ct, void *obj)
       ct->objs = EREALLOC(ContainerObject, ct->objs, ct->num_objs);
    else
      {
-       Efree(ct->objs);
-       ct->objs = NULL;
+       EFREE_NULL(ct->objs);
      }
 
    return 0;                   /* Success */
diff --git a/src/cursors.c b/src/cursors.c
index e27e6548..f5cedb3c 100644
--- a/src/cursors.c
+++ b/src/cursors.c
@@ -159,7 +159,7 @@ ECursorRealize(ECursor * ec)
    if (ec->file)
      {
        img = ThemeFileFind(ec->file, FILE_TYPE_CURSOR);
-       _EFREE(ec->file);       /* Ok or not - we never need file again */
+       EFREE_NULL(ec->file);   /* Ok or not - we never need file again */
        if (!img)
           goto done;
 
diff --git a/src/dialog.c b/src/dialog.c
index 56c25aea..cfbe307e 100644
--- a/src/dialog.c
+++ b/src/dialog.c
@@ -216,8 +216,7 @@ DialogBindKey(Dialog * d, const char *key, 
DialogCallbackFunc * func, int val,
 void
 DialogKeybindingsDestroy(Dialog * d)
 {
-   Efree(d->keybindings);
-   d->keybindings = NULL;
+   EFREE_NULL(d->keybindings);
    d->num_bindings = 0;
 }
 
@@ -278,8 +277,7 @@ DialogFind(const char *name)
 void
 DialogSetTitle(Dialog * d, const char *title)
 {
-   Efree(d->title);
-   d->title = Estrdup(title);
+   EFREE_DUP(d->title, title);
    d->set_title = 1;
 }
 
@@ -1513,8 +1511,7 @@ DialogItemsRealize(Dialog * d)
 void
 DialogItemSetText(DItem * di, const char *text)
 {
-   Efree(di->text);
-   di->text = Estrdup(text);
+   EFREE_DUP(di->text, text);
 
    if (di->realized)
       DialogDrawItems(di->dlg, di, di->x, di->y, di->w, di->h);
@@ -1591,8 +1588,7 @@ DialogItemSeparatorSetOrientation(DItem * di, char 
horizontal)
 void
 DialogItemImageSetFile(DItem * di, const char *image)
 {
-   Efree(di->item.image.image);
-   di->item.image.image = Estrdup(image);
+   EFREE_DUP(di->item.image.image, image);
    di->fill_h = 0;
    di->fill_v = 0;
 }
@@ -1725,8 +1721,7 @@ DialogItemTableEmpty(DItem * di)
    for (i = 0; i < di->item.table.num_items; i++)
       DialogItemDestroy(di->item.table.items[i], 1);
 
-   Efree(di->item.table.items);
-   di->item.table.items = NULL;
+   EFREE_NULL(di->item.table.items);
    di->item.table.num_items = 0;
 }
 
diff --git a/src/draw.c b/src/draw.c
index e7dcdadb..5c946ba4 100644
--- a/src/draw.c
+++ b/src/draw.c
@@ -288,8 +288,7 @@ DrawEwinShape(EWin * ewin, int md, int x, int y, int w, int 
h,
        if (firstlast == 2)
          {
             CoordsHide();
-            Efree(ewin->shape_data);
-            ewin->shape_data = NULL;
+            EFREE_NULL(ewin->shape_data);
          }
      }
 }
diff --git a/src/ecompmgr.c b/src/ecompmgr.c
index 10d70f75..6b17b4c7 100644
--- a/src/ecompmgr.c
+++ b/src/ecompmgr.c
@@ -1478,8 +1478,7 @@ ECompMgrWinDel(EObj * eo)
    REGION_DESTROY(cw->extents);
    REGION_DESTROY(cw->clip);
 
-   Efree(eo->cmhook);
-   eo->cmhook = NULL;
+   EFREE_NULL(eo->cmhook);
 
    _ECM_SET_STACK_CHANGED();
 }
@@ -2097,8 +2096,7 @@ ECompMgrShadowsInit(int mode, int cleanup)
       OpacityFix(Conf_compmgr.shadows.sharp.opacity, 100);
    Mode_compmgr.opac_sharp = .01f * Conf_compmgr.shadows.sharp.opacity;
 
-   Efree(gaussianMap);
-   gaussianMap = NULL;
+   EFREE_NULL(gaussianMap);
 
    if (mode != ECM_SHADOWS_OFF)
      {
diff --git a/src/eobj.c b/src/eobj.c
index 728bb8dc..96ff4fa0 100644
--- a/src/eobj.c
+++ b/src/eobj.c
@@ -292,8 +292,7 @@ EobjWindowCreate(int type, int x, int y, int w, int h, int 
su, const char *name)
    EobjInit(eo, type, EobjGetWin(eo), x, y, w, h, su, name);
    if (!eo->win)
      {
-       Efree(eo);
-       eo = NULL;
+       EFREE_NULL(eo);
      }
 
    return eo;
diff --git a/src/events.c b/src/events.c
index c343e610..d6a870c8 100644
--- a/src/events.c
+++ b/src/events.c
@@ -1096,8 +1096,7 @@ EventsMain(void)
             if ((evq_ptr) && ((evq_alloc - evq_fetch) > 64))
               {
                  evq_alloc = 0;
-                 Efree(evq_ptr);
-                 evq_ptr = NULL;
+                 EFREE_NULL(evq_ptr);
               }
          }
 
diff --git a/src/ewins.c b/src/ewins.c
index cd3ee175..8426286d 100644
--- a/src/ewins.c
+++ b/src/ewins.c
@@ -1624,8 +1624,8 @@ EwinSetTitle(EWin * ewin, const char *title)
 {
    HintsSetWindowName(EwinGetClientWin(ewin), title);
 
-   _EFDUP(ewin->o.icccm.wm_name, title);
-   _EFDUP(ewin->ewmh.wm_name, title);
+   EFREE_DUP(ewin->o.icccm.wm_name, title);
+   EFREE_DUP(ewin->ewmh.wm_name, title);
 }
 
 void
@@ -1633,8 +1633,8 @@ EwinSetClass(EWin * ewin, const char *name, const char 
*clss)
 {
    HintsSetWindowClass(EwinGetClientWin(ewin), name, clss);
 
-   _EFDUP(ewin->o.icccm.wm_res_name, name);
-   _EFDUP(ewin->o.icccm.wm_res_class, clss);
+   EFREE_DUP(ewin->o.icccm.wm_res_name, name);
+   EFREE_DUP(ewin->o.icccm.wm_res_class, clss);
 }
 
 const char         *
diff --git a/src/ewmh.c b/src/ewmh.c
index 7e02eb38..e1db990c 100644
--- a/src/ewmh.c
+++ b/src/ewmh.c
@@ -483,7 +483,7 @@ EWMH_GetWindowName(EWin * ewin)
 {
    char               *val;
 
-   _EFREE(ewin->ewmh.wm_name);
+   EFREE_NULL(ewin->ewmh.wm_name);
 
    ex_netwm_name_get(EwinGetClientXwin(ewin), &val);
    if (!val)
@@ -499,7 +499,7 @@ EWMH_GetWindowIconName(EWin * ewin)
 {
    char               *val;
 
-   _EFREE(ewin->ewmh.wm_icon_name);
+   EFREE_NULL(ewin->ewmh.wm_icon_name);
 
    ex_netwm_icon_name_get(EwinGetClientXwin(ewin), &val);
    if (!val)
@@ -634,8 +634,7 @@ EWMH_GetWindowIcons(EWin * ewin)
    unsigned int       *val;
    int                 num;
 
-   Efree(ewin->ewmh.wm_icon);
-   ewin->ewmh.wm_icon = NULL;
+   EFREE_NULL(ewin->ewmh.wm_icon);
 
    num = ex_window_prop_card32_list_get(EwinGetClientXwin(ewin),
                                        EX_ATOM_NET_WM_ICON, &val);
diff --git a/src/groups.c b/src/groups.c
index e2f17d67..714ae764 100644
--- a/src/groups.c
+++ b/src/groups.c
@@ -376,8 +376,7 @@ RemoveEwinFromGroup(EWin * ewin, Group * g)
                g->members = EREALLOC(EWin *, g->members, g->num_members);
             else if (g->save)
               {
-                 Efree(g->members);
-                 g->members = NULL;
+                 EFREE_NULL(g->members);
               }
             else
               {
@@ -390,8 +389,7 @@ RemoveEwinFromGroup(EWin * ewin, Group * g)
             ewin->num_groups--;
             if (ewin->num_groups <= 0)
               {
-                 Efree(ewin->groups);
-                 ewin->groups = NULL;
+                 EFREE_NULL(ewin->groups);
                  ewin->num_groups = 0;
               }
             else
diff --git a/src/icccm.c b/src/icccm.c
index b964877d..9ab224d0 100644
--- a/src/icccm.c
+++ b/src/icccm.c
@@ -92,7 +92,7 @@ ICCCM_ProcessRootClientMessage(XClientMessageEvent * event)
 void
 ICCCM_GetTitle(EWin * ewin)
 {
-   _EFREE(EwinGetIcccmName(ewin));
+   EFREE_NULL(EwinGetIcccmName(ewin));
 
    EwinGetIcccmName(ewin) = ex_icccm_title_get(EwinGetClientXwin(ewin));
 
@@ -555,8 +555,8 @@ ICCCM_GetGeoms(EWin * ewin)
 static void
 ICCCM_GetWmClass(EWin * ewin)
 {
-   _EFREE(EwinGetIcccmCName(ewin));
-   _EFREE(EwinGetIcccmClass(ewin));
+   EFREE_NULL(EwinGetIcccmCName(ewin));
+   EFREE_NULL(EwinGetIcccmClass(ewin));
 
    ex_icccm_name_class_get(EwinGetClientXwin(ewin),
                           &EwinGetIcccmCName(ewin), &EwinGetIcccmClass(ewin));
@@ -572,7 +572,7 @@ ICCCM_GetWmCommand(EWin * ewin)
    int                 argc;
    char              **argv, s[4096], *ss;
 
-   _EFREE(ewin->icccm.wm_command);
+   EFREE_NULL(ewin->icccm.wm_command);
 
    argc = ex_window_prop_string_list_get(EwinGetClientXwin(ewin),
                                         EX_ATOM_WM_COMMAND, &argv);
@@ -588,7 +588,7 @@ ICCCM_GetWmCommand(EWin * ewin)
 static void
 ICCCM_GetWmClientMachine(EWin * ewin)
 {
-   _EFREE(ewin->icccm.wm_machine);
+   EFREE_NULL(ewin->icccm.wm_machine);
 
    ewin->icccm.wm_machine =
       ex_window_prop_string_get(EwinGetClientXwin(ewin),
@@ -602,7 +602,7 @@ ICCCM_GetWmClientMachine(EWin * ewin)
 static void
 ICCCM_GetWmIconName(EWin * ewin)
 {
-   _EFREE(ewin->icccm.wm_icon_name);
+   EFREE_NULL(ewin->icccm.wm_icon_name);
 
    ewin->icccm.wm_icon_name =
       ex_window_prop_string_get(EwinGetClientXwin(ewin), EX_ATOM_WM_ICON_NAME);
@@ -614,7 +614,7 @@ ICCCM_GetWmIconName(EWin * ewin)
 static void
 ICCCM_GetWmWindowRole(EWin * ewin)
 {
-   _EFREE(ewin->icccm.wm_role);
+   EFREE_NULL(ewin->icccm.wm_role);
    ewin->icccm.wm_role =
       ex_window_prop_string_get(EwinGetClientXwin(ewin),
                                EX_ATOM_WM_WINDOW_ROLE);
diff --git a/src/iclass.c b/src/iclass.c
index 92fe7f59..5f42649a 100644
--- a/src/iclass.c
+++ b/src/iclass.c
@@ -220,13 +220,11 @@ ImagestateRealize(ImageState * is)
        Eprintf
           ("%s: Hmmm... is->im is NULL (im_file=%s real_file=%s)\n", __func__,
            S(is->im_file), S(is->real_file));
-       Efree(is->real_file);
-       is->real_file = NULL;
+       EFREE_NULL(is->real_file);
        return;
      }
 
-   Efree(is->im_file);         /* We no longer need the file */
-   is->im_file = NULL;
+   EFREE_NULL(is->im_file);
 
    EImageCheckAlpha(is->im);
 
diff --git a/src/ipc.c b/src/ipc.c
index 811fd023..0fbd3f89 100644
--- a/src/ipc.c
+++ b/src/ipc.c
@@ -63,8 +63,7 @@ IpcPrintInit(void)
 static void
 IpcPrintDone(void)
 {
-   Efree(ipc_bufptr);
-   ipc_bufptr = NULL;
+   EFREE_NULL(ipc_bufptr);
    ipc_bufsiz = 0;
    ipc_active = 0;
 }
diff --git a/src/lang.c b/src/lang.c
index 1698262e..4d698aba 100644
--- a/src/lang.c
+++ b/src/lang.c
@@ -439,7 +439,7 @@ LangCfgChange(void *item __UNUSED__, const char *locale)
    if (*locale == '\0')
       locale = NULL;
    LangExit();
-   _EFDUP(Conf_locale.internal, locale);
+   EFREE_DUP(Conf_locale.internal, locale);
    LangInit();
 }
 
diff --git a/src/main.c b/src/main.c
index 93249d24..117e5940 100644
--- a/src/main.c
+++ b/src/main.c
@@ -500,23 +500,20 @@ RunInitPrograms(void)
 static void
 EConfNameSet(const char *name)
 {
-   Efree(Mode.conf.name);
-   Mode.conf.name = Estrdup(name);
+   EFREE_DUP(Mode.conf.name, name);
    Esetenv("ECONFNAME", Mode.conf.name);
 }
 
 static void
 EDirUserSet(const char *dir)
 {
-   Efree(Mode.conf.dir);
-   Mode.conf.dir = Estrdup(dir);
+   EFREE_DUP(Mode.conf.dir, dir);
 }
 
 static void
 EDirUserCacheSet(const char *dir)
 {
-   Efree(Mode.conf.cache_dir);
-   Mode.conf.cache_dir = Estrdup(dir);
+   EFREE_DUP(Mode.conf.cache_dir, dir);
 }
 
 void
diff --git a/src/menus.c b/src/menus.c
index fbc58af8..a69f5a4c 100644
--- a/src/menus.c
+++ b/src/menus.c
@@ -479,19 +479,19 @@ MenuSetTransient(Menu * m)
 void
 MenuSetName(Menu * m, const char *name)
 {
-   _EFDUP(m->name, name);
+   EFREE_DUP(m->name, name);
 }
 
 void
 MenuSetAlias(Menu * m, const char *alias)
 {
-   _EFDUP(m->alias, alias);
+   EFREE_DUP(m->alias, alias);
 }
 
 void
 MenuSetTitle(Menu * m, const char *title)
 {
-   _EFDUP(m->title, title);
+   EFREE_DUP(m->title, title);
 }
 
 void
@@ -505,8 +505,7 @@ MenuSetIconSize(Menu * m, int size)
 void
 MenuSetData(Menu * m, char *data)
 {
-   Efree(m->data);
-   m->data = data;
+   EFREE_SET(m->data, data);
 }
 
 void
@@ -633,8 +632,7 @@ MenuEmpty(Menu * m, int destroying)
           EventCallbackUnregister(mi->win, MenuItemHandleEvents, mi);
        Efree(mi);
      }
-   Efree(m->items);
-   m->items = NULL;
+   EFREE_NULL(m->items);
    m->num = 0;
    m->sel_item = NULL;
 
@@ -748,8 +746,7 @@ MenuRealize(Menu * m)
                  im = EImageLoad(s);
                  if (im)
                    {
-                      Efree(m->items[i]->icon);
-                      m->items[i]->icon = s;
+                      EFREE_SET(m->items[i]->icon, s);
                    }
               }
             if (im)
@@ -771,8 +768,7 @@ MenuRealize(Menu * m)
               }
             else
               {
-                 Efree(m->items[i]->icon);
-                 m->items[i]->icon = NULL;
+                 EFREE_NULL(m->items[i]->icon);
               }
          }
      }
@@ -1733,7 +1729,7 @@ MenuStyleConfigLoad(FILE * fs)
             ms->maxy = atoi(s2);
             break;
          case CONFIG_BORDER:
-            _EFDUP(ms->border_name, s2);
+            EFREE_DUP(ms->border_name, s2);
             break;
          default:
             break;
@@ -1779,8 +1775,8 @@ MenuConfigLoad(FILE * fs)
             if (i2 != CONFIG_OPEN)
                goto done;
             m = NULL;
-            _EFREE(txt);
-            _EFREE(icon);
+            EFREE_NULL(txt);
+            EFREE_NULL(icon);
             continue;
          case CONFIG_CLOSE:
             err = 0;
@@ -1807,8 +1803,8 @@ MenuConfigLoad(FILE * fs)
             continue;
 
          case MENU_ITEM:
-            _EFREE(txt);
-            _EFREE(icon);
+            EFREE_NULL(txt);
+            EFREE_NULL(icon);
             if (strcmp("NULL", s2))
                icon = Estrdup(s2);
             if (p3 && *p3)
@@ -1848,14 +1844,14 @@ MenuConfigLoad(FILE * fs)
                       mi = MenuItemCreate(txt, icon, p2, NULL);
                       MenuAddItem(m, mi);
                    }
-                 _EFREE(txt);
-                 _EFREE(icon);
+                 EFREE_NULL(txt);
+                 EFREE_NULL(icon);
               }
             break;
          case MENU_SUBMENU:
             len = 0;
             sscanf(p3, "%s %n", s3, &len);
-            _EFREE(icon);
+            EFREE_NULL(icon);
             if (strcmp("NULL", s3))
                icon = Estrdup(s3);
             mm = MenuFind(s2, NULL);
@@ -1870,7 +1866,7 @@ MenuConfigLoad(FILE * fs)
  done:
    if (err)
       ConfigAlertLoad("Menu");
-   _EFREE(txt);
+   EFREE_NULL(txt);
 
    return err;
 }
diff --git a/src/pager.c b/src/pager.c
index 9ac921a5..438d4252 100644
--- a/src/pager.c
+++ b/src/pager.c
@@ -1326,8 +1326,8 @@ PagerEwinGroupSet(void)
 static void
 PagerEwinGroupUnset(void)
 {
-   _EFREE(gwin_px);
-   _EFREE(gwin_py);
+   EFREE_NULL(gwin_px);
+   EFREE_NULL(gwin_py);
 }
 
 static void
diff --git a/src/progress.c b/src/progress.c
index fd4d1c37..afa02466 100644
--- a/src/progress.c
+++ b/src/progress.c
@@ -123,7 +123,7 @@ ProgressbarDestroy(Progressbar * p)
    if (pnum <= 0)
      {
        pnum = 0;
-       _EFREE(plist);
+       EFREE_NULL(plist);
      }
    else
      {
diff --git a/src/session.c b/src/session.c
index 9f908acd..edf4f702 100644
--- a/src/session.c
+++ b/src/session.c
@@ -434,7 +434,7 @@ SessionGetInfo(EWin * ewin __UNUSED__)
 #if USE_SM
    if (atom_sm_client_id == NoXID)
       return;
-   _EFREE(ewin->session_id);
+   EFREE_NULL(ewin->session_id);
    if (ewin->icccm.client_leader != NoXID)
       ewin->session_id =
         ex_window_prop_string_get(ewin->icccm.client_leader,
diff --git a/src/snaps.c b/src/snaps.c
index 48fe9e8f..134025a4 100644
--- a/src/snaps.c
+++ b/src/snaps.c
@@ -306,8 +306,7 @@ _SnapEwinGet(EWin * ewin, unsigned int match_flags)
 static void
 _SnapUpdateEwinBorder(Snapshot * sn, const EWin * ewin)
 {
-   Efree(sn->border_name);
-   sn->border_name = Estrdup(BorderGetName(ewin->normal_border));
+   EFREE_DUP(sn->border_name, BorderGetName(ewin->normal_border));
 }
 
 static void
@@ -379,8 +378,7 @@ _SnapUpdateEwinCmd(Snapshot * sn, const EWin * ewin)
        strcmp(ewin->icccm.wm_machine, Mode.wm.machine_name))
       return;
 
-   Efree(sn->cmd);
-   sn->cmd = Estrdup(ewin->icccm.wm_command);
+   EFREE_DUP(sn->cmd, ewin->icccm.wm_command);
 }
 
 static void
@@ -395,8 +393,7 @@ _SnapUpdateEwinGroups(Snapshot * sn, const EWin * ewin, 
char onoff)
 
    if (!ewin->groups)
      {
-       Efree(sn->groups);
-       sn->groups = NULL;
+       EFREE_NULL(sn->groups);
        sn->num_groups = 0;
        return;
      }
@@ -418,8 +415,7 @@ _SnapUpdateEwinGroups(Snapshot * sn, const EWin * ewin, 
char onoff)
                continue;
 
             sn->num_groups = num_groups;
-            Efree(sn->groups);
-            sn->groups = EMALLOC(int, num_groups);
+            EFREE_SET(sn->groups, EMALLOC(int, num_groups));
 
             for (j = 0; j < num_groups; j++)
               {
@@ -434,8 +430,7 @@ _SnapUpdateEwinGroups(Snapshot * sn, const EWin * ewin, 
char onoff)
                  sn = gwins[i]->snap;
                  if (sn)
                    {
-                      Efree(sn->groups);
-                      sn->groups = NULL;
+                      EFREE_NULL(sn->groups);
                       sn->num_groups = 0;
                    }
               }
@@ -960,8 +955,7 @@ _DlgApplyRemember(Dialog * d __UNUSED__,
 static void
 _DlgExitRemember(Dialog * d __UNUSED__)
 {
-   Efree(rd_ewin_list);
-   rd_ewin_list = NULL;
+   EFREE_NULL(rd_ewin_list);
 }
 
 static void
diff --git a/src/sound.c b/src/sound.c
index ec28a9b0..98cd4c95 100644
--- a/src/sound.c
+++ b/src/sound.c
@@ -398,7 +398,7 @@ _SoundThemeChange(void *item __UNUSED__, const char *theme)
    if (*theme == '\0')
       theme = NULL;
    _SoundConfigUnload();
-   _EFDUP(Conf_sound.theme, theme);
+   EFREE_DUP(Conf_sound.theme, theme);
    _SoundConfigLoad();
 }
 
diff --git a/src/sound_esd.c b/src/sound_esd.c
index 2155d889..dbe99355 100644
--- a/src/sound_esd.c
+++ b/src/sound_esd.c
@@ -85,9 +85,9 @@ _sound_esd_Load(const char *file)
      }
 
  done:
-   _EFREE(s->ssd.data);
+   EFREE_NULL(s->ssd.data);
    if (s->id <= 0)
-      _EFREE(s);
+      EFREE_NULL(s);
 
    return s;
 }
@@ -105,7 +105,7 @@ _sound_esd_Destroy(Sample * s)
 /*      esd_sample_kill(sound_fd,s->id); */
        esd_sample_free(sound_fd, s->id);
      }
-   _EFREE(s->ssd.data);
+   EFREE_NULL(s->ssd.data);
    Efree(s);
 }
 
diff --git a/src/sound_load.c b/src/sound_load.c
index 74e389a7..e8bfbe8e 100644
--- a/src/sound_load.c
+++ b/src/sound_load.c
@@ -67,7 +67,7 @@ SoundSampleGetData(const char *file, SoundSampleData * ssd)
    if (frames_read <= 0)
      {
        ssd->size = 0;
-       _EFREE(ssd->data);
+       EFREE_NULL(ssd->data);
        return -1;
      }
 
@@ -111,7 +111,7 @@ SoundSampleGetData(const char *file, SoundSampleData * ssd)
    if (frames_read <= 0)
      {
        ssd->size = 0;
-       _EFREE(ssd->data);
+       EFREE_NULL(ssd->data);
        return -1;
      }
 
diff --git a/src/sound_pa.c b/src/sound_pa.c
index 393a31ff..50422b2e 100644
--- a/src/sound_pa.c
+++ b/src/sound_pa.c
@@ -197,8 +197,8 @@ _sound_pa_Destroy(Sample * s)
      }
    D2printf("%s end\n", __func__);
 
-   _EFREE(s->name);
-   _EFREE(s->ssd.data);
+   EFREE_NULL(s->name);
+   EFREE_NULL(s->ssd.data);
    Efree(s);
 }
 
@@ -254,7 +254,7 @@ _sound_pa_Load(const char *file)
    if (err)
       goto bail_out;
 
-   _EFREE(s->ssd.data);
+   EFREE_NULL(s->ssd.data);
 
    return s;
 
diff --git a/src/stacking.c b/src/stacking.c
index f8d34a45..7dea6d08 100644
--- a/src/stacking.c
+++ b/src/stacking.c
@@ -149,8 +149,7 @@ EobjListDel(EobjList * ewl, EObj * eo)
    else if (ewl->nwins <= 0)
      {
        /* Enables autocleanup at shutdown, if ever implemented */
-       Efree(ewl->list);
-       ewl->list = NULL;
+       EFREE_NULL(ewl->list);
        ewl->nalloc = 0;
      }
 
diff --git a/src/theme.c b/src/theme.c
index 28bb9adf..b27ea5e3 100644
--- a/src/theme.c
+++ b/src/theme.c
@@ -37,7 +37,7 @@ _ThemePathsUpdate(void)
    Esnprintf(paths, sizeof(paths), "%s/themes:%s/.themes:%s/themes:%s",
             EDirUser(), userhome(), EDirRoot(),
             (Conf.theme.extra_path) ? Conf.theme.extra_path : "");
-   _EFDUP(Mode.theme.paths, paths);
+   EFREE_DUP(Mode.theme.paths, paths);
 }
 
 /* Check if this is a theme dir */
@@ -357,7 +357,7 @@ ThemeFind(const char *theme)
       *s++ = '\0';
 
    p = (theme && *theme == ':') ? theme + 1 : s;
-   _EFDUP(Mode.theme.variant, p);
+   EFREE_DUP(Mode.theme.variant, p);
 
    path = ThemePathFind(name);
 
@@ -385,8 +385,7 @@ ThemeFind(const char *theme)
          }
      }
 
-   Efree(Mode.theme.path);
-   Mode.theme.path = (path) ? path : Estrdup("-");
+   EFREE_SET(Mode.theme.path, (path) ? path : Estrdup("-"));
 }
 
 #if ENABLE_DIALOGS
diff --git a/src/util.h b/src/util.h
index f56b7236..2a23a654 100644
--- a/src/util.h
+++ b/src/util.h
@@ -83,8 +83,9 @@ const char         *Estrcasestr(const char *haystack, const 
char *needle);
 #define EMALLOC(type, num) (type*)Emalloc((num)*sizeof(type))
 #define EREALLOC(type, ptr, num) (type*)Erealloc(ptr, (num)*sizeof(type))
 
-#define _EFREE(p)    do { if (p) { Efree(p); p = NULL; } } while (0)
-#define _EFDUP(p, s) do { if (p) Efree(p); p = Estrdup(s); } while (0)
+#define EFREE_NULL(p)   do { Efree(p); p = NULL; } while (0)
+#define EFREE_SET(p, s) do { Efree(p); p = s; } while (0)
+#define EFREE_DUP(p, s) do { Efree(p); p = Estrdup(s); } while (0)
 
 #define STRCPY(dst, src) do { src[sizeof(dst)-1] = '\0'; strcpy(dst, src); } 
while(0)
 
diff --git a/src/warp.c b/src/warp.c
index 4bfe0716..09f00e81 100644
--- a/src/warp.c
+++ b/src/warp.c
@@ -316,8 +316,7 @@ WarpFocusHide(void)
    if (fw && EoIsShown(fw))
       WarpFocusWinHide(fw);
 
-   Efree(warplist);
-   warplist = NULL;
+   EFREE_NULL(warplist);
    warplist_num = 0;
 }
 
diff --git a/src/windowmatch.c b/src/windowmatch.c
index 2c70804e..e97d623e 100644
--- a/src/windowmatch.c
+++ b/src/windowmatch.c
@@ -653,8 +653,7 @@ WindowMatchEwinOpsAction(EWin * ewin, int op, const char 
*args)
        return;
 
      case EWIN_OP_TITLE:
-       Efree(EwinGetIcccmName(ewin));
-       EwinGetIcccmName(ewin) = Estrdup(args);
+       EFREE_DUP(EwinGetIcccmName(ewin), args);
        break;
 
      case EWIN_OP_ICONIFY:
diff --git a/src/x.c b/src/x.c
index 949cfdb5..205d8388 100644
--- a/src/x.c
+++ b/src/x.c
@@ -243,8 +243,7 @@ EventCallbackUnregister(Win win, EventCallbackFunc * func, 
void *prm)
             }
           else
             {
-               Efree(win->cbl.lst);
-               win->cbl.lst = NULL;
+               EFREE_NULL(win->cbl.lst);
             }
           return;
        }

-- 


Reply via email to