Remove pointless if before calling free.
The free() function frees the memory space pointed to by ptr, which must
have been returned by a previous call to malloc(), calloc() or
realloc(). Otherwise, or if free(ptr) has already been called before,
undefined behavior occurs. If ptr is NULL, no operation is performed.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-- man malloc(3)
This commit is contained in:
parent
c174e69b64
commit
a5432919ca
@ -100,7 +100,7 @@ draw_image_ofset_text(Drawable d, int x, int y, char* fg, char *str, int x_image
|
||||
if(strstr(ostr, "i["))
|
||||
strncpy(str, ostr, textlen);
|
||||
|
||||
IFREE(ostr);
|
||||
free(ostr);
|
||||
#endif /* HAVE_IMLIB */
|
||||
|
||||
return;
|
||||
@ -226,7 +226,7 @@ textw(char *text)
|
||||
if(strstr(ostr, "i["))
|
||||
strncpy(text, ostr, textlen);
|
||||
|
||||
IFREE(ostr);
|
||||
free(ostr);
|
||||
#endif /* HAVE_IMLIB */
|
||||
|
||||
return gl.width + font->descent;
|
||||
|
||||
@ -74,8 +74,8 @@ getinfo_tag(void)
|
||||
printf("Current tag: %d - %s\n", tag, tag_name);
|
||||
printf("Tag list: %s\n", tag_list);
|
||||
|
||||
IFREE(tag_name);
|
||||
IFREE(tag_list);
|
||||
free(tag_name);
|
||||
free(tag_list);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -122,7 +122,7 @@ getinfo_layout(void)
|
||||
|
||||
printf("Current layout: %s\n", layout);
|
||||
|
||||
IFREE(layout);
|
||||
free(layout);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -143,7 +143,7 @@ getinfo_mwfact(void)
|
||||
|
||||
printf("Current mwfact: %s\n", mwfact);
|
||||
|
||||
IFREE(mwfact);
|
||||
free(mwfact);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -209,7 +209,7 @@ infobar_draw_selbar(int sc)
|
||||
|
||||
barwin_refresh(infobar[sc].selbar);
|
||||
|
||||
IFREE(str);
|
||||
free(str);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -370,7 +370,7 @@ complete_on_files(char *start, size_t hits)
|
||||
else
|
||||
warn("%s", filepath);
|
||||
|
||||
IFREE(filepath);
|
||||
free(filepath);
|
||||
|
||||
break;
|
||||
}
|
||||
@ -378,8 +378,8 @@ complete_on_files(char *start, size_t hits)
|
||||
closedir(dir);
|
||||
}
|
||||
|
||||
IFREE(dirname);
|
||||
IFREE(path);
|
||||
free(dirname);
|
||||
free(path);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -345,7 +345,7 @@ uicb_menu(uicb_t cmd)
|
||||
void
|
||||
menu_clear(Menu *menu)
|
||||
{
|
||||
IFREE(menu->item);
|
||||
free(menu->item);
|
||||
menu->nitem = 0;
|
||||
|
||||
return;
|
||||
|
||||
@ -118,7 +118,7 @@ systray_del(Systray *s)
|
||||
for(ss = &trayicons; *ss && *ss != s; ss = &(*ss)->next);
|
||||
*ss = s->next;
|
||||
|
||||
IFREE(s);
|
||||
free(s);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -162,7 +162,7 @@ systray_freeicons(void)
|
||||
{
|
||||
XUnmapWindow(dpy, i->win);
|
||||
XReparentWindow(dpy, i->win, ROOT, 0, 0);
|
||||
IFREE(i);
|
||||
free(i);
|
||||
}
|
||||
|
||||
XSetSelectionOwner(dpy, net_atom[net_system_tray_s], None, CurrentTime);
|
||||
|
||||
34
src/wmfs.c
34
src/wmfs.c
@ -92,8 +92,8 @@ quit(void)
|
||||
XReparentWindow(dpy, c->win, ROOT, c->geo.x, c->geo.y);
|
||||
}
|
||||
|
||||
IFREE(tags);
|
||||
IFREE(seltag);
|
||||
free(tags);
|
||||
free(seltag);
|
||||
|
||||
systray_freeicons();
|
||||
|
||||
@ -103,31 +103,31 @@ quit(void)
|
||||
XFreeGC(dpy, gc_stipple);
|
||||
infobar_destroy();
|
||||
|
||||
IFREE(sgeo);
|
||||
IFREE(spgeo);
|
||||
IFREE(infobar);
|
||||
IFREE(keys);
|
||||
IFREE(net_atom);
|
||||
free(sgeo);
|
||||
free(spgeo);
|
||||
free(infobar);
|
||||
free(keys);
|
||||
free(net_atom);
|
||||
|
||||
/* Clean conf alloced thing */
|
||||
IFREE(menulayout.item);
|
||||
free(menulayout.item);
|
||||
|
||||
if(conf.menu)
|
||||
{
|
||||
len = LEN(conf.menu);
|
||||
for(i = 0; i < len; ++i)
|
||||
IFREE(conf.menu[i].item);
|
||||
IFREE(conf.menu);
|
||||
free(conf.menu[i].item);
|
||||
free(conf.menu);
|
||||
}
|
||||
|
||||
IFREE(conf.launcher);
|
||||
IFREE(conf.rule);
|
||||
free(conf.launcher);
|
||||
free(conf.rule);
|
||||
|
||||
IFREE(conf.bars.mouse);
|
||||
IFREE(conf.selbar.mouse);
|
||||
IFREE(conf.titlebar.button);
|
||||
IFREE(conf.client.mouse);
|
||||
IFREE(conf.root.mouse);
|
||||
free(conf.bars.mouse);
|
||||
free(conf.selbar.mouse);
|
||||
free(conf.titlebar.button);
|
||||
free(conf.client.mouse);
|
||||
free(conf.root.mouse);
|
||||
|
||||
free_conf();
|
||||
|
||||
|
||||
@ -108,7 +108,6 @@
|
||||
#define FRAMEH(h) ((h) + (BORDH + TBARH))
|
||||
#define ROUND(x) (float)((x > 0) ? x + (float)0.5 : x - (float)0.5)
|
||||
#define CHECK(x) if(!(x)) return
|
||||
#define IFREE(x) if(x) free(x)
|
||||
#define LEN(x) (sizeof(x) / sizeof((x)[0]))
|
||||
#define MAXCLIST (64)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user