From a409913c5faa3f16f2f7ff7eabeb6149d62de02c Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Mon, 6 May 2019 01:41:36 +0100 Subject: [PATCH] common.h: remove cxfree Apparently XFree does take NULL. Signed-off-by: Yuxuan Shui --- src/c2.c | 2 +- src/common.h | 10 ---------- src/compton.c | 2 +- src/compton.h | 6 +++--- src/opengl.c | 2 +- src/win.c | 4 ++-- src/x.c | 4 ++-- 7 files changed, 10 insertions(+), 20 deletions(-) diff --git a/src/c2.c b/src/c2.c index ad8a1ae..8373f27 100644 --- a/src/c2.c +++ b/src/c2.c @@ -1455,7 +1455,7 @@ static inline void c2_match_once_leaf(session_t *ps, const struct managed_win *w // Free the string after usage, if necessary if (tgt_free) { if (C2_L_TATOM == pleaf->type) - cxfree(tgt_free); + XFree(tgt_free); else free(tgt_free); } diff --git a/src/common.h b/src/common.h index a2a0c08..8269f10 100644 --- a/src/common.h +++ b/src/common.h @@ -538,16 +538,6 @@ static inline struct timespec get_time_timespec(void) { return tm; } -/** - * Wrapper of XFree() for convenience. - * - * Because a NULL pointer cannot be passed to XFree(), its man page says. - */ -static inline void cxfree(void *data) { - if (data) - XFree(data); -} - /** * Return the painting target window. */ diff --git a/src/compton.c b/src/compton.c index a52e8d1..6e2ab7b 100644 --- a/src/compton.c +++ b/src/compton.c @@ -913,7 +913,7 @@ static bool register_cm(session_t *ps) { } Xutf8SetWMProperties(ps->dpy, ps->reg_win, "compton", "compton", NULL, 0, NULL, NULL, h); - cxfree(h); + XFree(h); } // Set _NET_WM_PID diff --git a/src/compton.h b/src/compton.h index 8d0a79e..3d016a9 100644 --- a/src/compton.h +++ b/src/compton.h @@ -113,7 +113,7 @@ static inline XTextProperty *make_text_prop(session_t *ps, char *str) { XTextProperty *pprop = ccalloc(1, XTextProperty); if (XmbTextListToTextProperty(ps->dpy, &str, 1, XStringStyle, pprop)) { - cxfree(pprop->value); + XFree(pprop->value); free(pprop); pprop = NULL; } @@ -133,8 +133,8 @@ wid_set_text_prop(session_t *ps, xcb_window_t wid, xcb_atom_t prop_atom, char *s } XSetTextProperty(ps->dpy, wid, pprop, prop_atom); - cxfree(pprop->value); - cxfree(pprop); + XFree(pprop->value); + XFree(pprop); return true; } diff --git a/src/opengl.c b/src/opengl.c index d106d4b..839adfc 100644 --- a/src/opengl.c +++ b/src/opengl.c @@ -197,7 +197,7 @@ bool glx_init(session_t *ps, bool need_render) { success = true; glx_init_end: - cxfree(pvis); + XFree(pvis); if (!success) glx_destroy(ps); diff --git a/src/win.c b/src/win.c index e7d7311..f2cd554 100644 --- a/src/win.c +++ b/src/win.c @@ -310,10 +310,10 @@ int win_get_name(session_t *ps, struct managed_win *w) { !nstr || !strlst) { if (strlst) XFreeStringList(strlst); - cxfree(text_prop.value); + XFree(text_prop.value); return -1; } - cxfree(text_prop.value); + XFree(text_prop.value); } int ret = 0; diff --git a/src/x.c b/src/x.c index ffc5f91..a2cbce1 100644 --- a/src/x.c +++ b/src/x.c @@ -100,11 +100,11 @@ bool wid_get_text_prop(session_t *ps, xcb_window_t wid, xcb_atom_t prop, char ** *pnstr = 0; if (*pstrlst) XFreeStringList(*pstrlst); - cxfree(text_prop.value); + XFree(text_prop.value); return false; } - cxfree(text_prop.value); + XFree(text_prop.value); return true; }