summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérémie Courrèges-Anglas <jca@wxcvbn.org>2014-01-03 22:18:51 +0100
committerJérémie Courrèges-Anglas <jca@wxcvbn.org>2014-01-03 23:06:29 +0100
commitb8d5ca85d9a6e6f42b8dbd6d47cab7bbcffeea90 (patch)
treea64f9b23e4f98279712d3d29bd37659996ce4c39
parent268732324fd37d9b001694a9206a66cce6681c20 (diff)
downloadratpoison-b8d5ca85d9a6e6f42b8dbd6d47cab7bbcffeea90.zip
if (ptr) free(ptr) is not a good idiom.
-rw-r--r--src/actions.c10
-rw-r--r--src/completions.c6
-rw-r--r--src/events.c3
-rw-r--r--src/globals.c6
-rw-r--r--src/group.c6
-rw-r--r--src/main.c3
-rw-r--r--src/sbuf.c4
7 files changed, 13 insertions, 25 deletions
diff --git a/src/actions.c b/src/actions.c
index 2d06645..886b99a 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -431,7 +431,7 @@ clear_frame_redos (void)
list_for_each_safe_entry (cur, iter, tmp, &rp_frame_redos, node)
{
- if (cur->frames) free (cur->frames);
+ free (cur->frames);
list_del (&(cur->node));
}
}
@@ -440,7 +440,7 @@ void
del_frame_undo (rp_frame_undo *u)
{
if (!u) return;
- if (u->frames) free (u->frames);
+ free (u->frames);
list_del (&(u->node));
free (u);
}
@@ -831,8 +831,7 @@ cmdret_new (int success, char *fmt, ...)
void
cmdret_free (cmdret *ret)
{
- if (ret->output)
- free (ret->output);
+ free (ret->output);
free (ret);
}
@@ -2422,8 +2421,7 @@ arg_free (struct cmdarg *arg)
if (arg)
{
/* read_frame doesn't fill in string. */
- if (arg->string)
- free (arg->string);
+ free (arg->string);
switch (arg->type)
{
case arg_KEY:
diff --git a/src/completions.c b/src/completions.c
index fc32c38..a047a50 100644
--- a/src/completions.c
+++ b/src/completions.c
@@ -53,8 +53,7 @@ completions_free (rp_completions *c)
}
/* Free the partial string. */
- if (c->partial)
- free (c->partial);
+ free (c->partial);
free (c);
}
@@ -88,8 +87,7 @@ completions_update (rp_completions *c, char *partial)
new_list = c->complete_fn (partial);
c->virgin = 0;
- if (c->partial)
- free (c->partial);
+ free (c->partial);
c->partial = xstrdup (partial);
completions_assign (c, new_list);
diff --git a/src/events.c b/src/events.c
index 37bfc01..8c8950d 100644
--- a/src/events.c
+++ b/src/events.c
@@ -788,8 +788,7 @@ selection_request (XSelectionRequestEvent *rq)
static void
selection_clear (void)
{
- if (selection.text)
- free (selection.text);
+ free (selection.text);
selection.text = NULL;
selection.len = 0;
}
diff --git a/src/globals.c b/src/globals.c
index 233f2ae..f81d7ad 100644
--- a/src/globals.c
+++ b/src/globals.c
@@ -108,8 +108,7 @@ set_nselection (char *txt, int len)
int i;
/* Update the selection structure */
- if (selection.text != NULL)
- free(selection.text);
+ free (selection.text);
/* Copy the string by hand. */
selection.text = malloc(len+1);
@@ -125,8 +124,7 @@ void
set_selection (char *txt)
{
/* Update the selection structure */
- if (selection.text != NULL)
- free(selection.text);
+ free (selection.text);
selection.text = xstrdup (txt);
selection.len = strlen (txt);
diff --git a/src/group.c b/src/group.c
index 2bbfead..348ffcc 100644
--- a/src/group.c
+++ b/src/group.c
@@ -144,8 +144,7 @@ group_new (int number, char *name)
void
group_free (rp_group *g)
{
- if (g->name)
- free (g->name);
+ free (g->name);
numset_free (g->numset);
numset_release (group_numset, g->number);
free (g);
@@ -195,8 +194,7 @@ group_resort_group (rp_group *g)
void
group_rename (rp_group *g, char *name)
{
- if (g->name)
- free (g->name);
+ free (g->name);
g->name = xstrdup (name);
}
diff --git a/src/main.c b/src/main.c
index ab1f592..f8d3fed 100644
--- a/src/main.c
+++ b/src/main.c
@@ -297,8 +297,7 @@ handler (Display *d, XErrorEvent *e)
/* If there is already an error to report, replace it with this new
one. */
- if (rp_error_msg)
- free (rp_error_msg);
+ free (rp_error_msg);
rp_error_msg = xstrdup (error_msg);
return 0;
diff --git a/src/sbuf.c b/src/sbuf.c
index 055006d..d85ed47 100644
--- a/src/sbuf.c
+++ b/src/sbuf.c
@@ -46,9 +46,7 @@ sbuf_free (struct sbuf *b)
{
if (b != NULL)
{
- if (b->data != NULL)
- free (b->data);
-
+ free (b->data);
free (b);
}
}