[awesome] Remove checking for value before p_delete()'ing memory

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-05-02 10:31:51 +02:00
parent a3a47d718e
commit dc27cff8ab
6 changed files with 19 additions and 30 deletions

View File

@ -1143,25 +1143,26 @@ static int
getline(char **buf, size_t *len, FILE* in) getline(char **buf, size_t *len, FILE* in)
{ {
int i; int i;
if (*buf) {
if (*buf)
p_delete(buf); p_delete(buf);
(*buf) = NULL;
}
if (*len) if (*len)
*len = 0; *len = 0;
do { do
{
p_realloc(buf, *len + 10); p_realloc(buf, *len + 10);
(*len) += 10; (*len) += 10;
for (i = 0; i < 10 && !feof(in); i++) { for (i = 0; i < 10 && !feof(in); i++)
{
(*buf)[*len - 10 + i] = getchar(); (*buf)[*len - 10 + i] = getchar();
if ((*buf)[*len - 10 + i] == '\n' || if ((*buf)[*len - 10 + i] == '\n'
(*buf)[*len - 10 + i] == '\r') { || (*buf)[*len - 10 + i] == '\r')
return (*len - 10 + i + 1); return (*len - 10 + i + 1);
} }
} }
}
while(!feof(in)); while(!feof(in));
return -1; return -1;
} }
#endif #endif
@ -1195,7 +1196,6 @@ item_list_fill_stdin(void)
} }
while((line_len = getline(&buf, &len, stdin)) != -1); while((line_len = getline(&buf, &len, stdin)) != -1);
if(buf)
p_delete(&buf); p_delete(&buf);
return has_entry; return has_entry;

View File

@ -128,7 +128,6 @@ scan()
!(attr_r->map_state == XCB_MAP_STATE_VIEWABLE || !(attr_r->map_state == XCB_MAP_STATE_VIEWABLE ||
window_getstate(wins[i]) == XCB_WM_ICONIC_STATE)) window_getstate(wins[i]) == XCB_WM_ICONIC_STATE))
{ {
if(attr_r)
p_delete(&attr_r); p_delete(&attr_r);
continue; continue;
} }

View File

@ -57,7 +57,6 @@ xutil_gettextprop(xcb_connection_t *conn, xcb_window_t w, xcb_atom_t atom,
if(!prop_r || !prop_r->value_len || prop_r->format != 8) if(!prop_r || !prop_r->value_len || prop_r->format != 8)
{ {
if(prop_r)
p_delete(&prop_r); p_delete(&prop_r);
return false; return false;
} }
@ -143,9 +142,7 @@ xutil_get_transient_for_hint(xcb_connection_t *c, xcb_window_t win,
t_hint_r->length == 0) t_hint_r->length == 0)
{ {
*prop_win = XCB_NONE; *prop_win = XCB_NONE;
if(t_hint_r)
p_delete(&t_hint_r); p_delete(&t_hint_r);
return false; return false;
} }
@ -198,9 +195,7 @@ xutil_get_class_hint(xcb_connection_t *conn, xcb_window_t win)
if(!class_hint_r || class_hint_r->type != STRING || if(!class_hint_r || class_hint_r->type != STRING ||
class_hint_r->format != 8) class_hint_r->format != 8)
{ {
if(class_hint_r)
p_delete(&class_hint_r); p_delete(&class_hint_r);
return NULL; return NULL;
} }

2
ewmh.c
View File

@ -437,9 +437,7 @@ ewmh_get_window_icon(xcb_window_t w)
if(!r || r->type != CARDINAL || r->format != 32 || r->length < 2 || if(!r || r->type != CARDINAL || r->format != 32 || r->length < 2 ||
!(data = (uint32_t *) xcb_get_property_value(r))) !(data = (uint32_t *) xcb_get_property_value(r)))
{ {
if(r)
p_delete(&r); p_delete(&r);
return NULL; return NULL;
} }

View File

@ -71,9 +71,7 @@ rule_matching_client(client_t *c)
snprintf(prop, len, "%s:%s:%s", snprintf(prop, len, "%s:%s:%s",
ch->res_class ? ch->res_class : "", ch->res_name ? ch->res_name : "", c->name); ch->res_class ? ch->res_class : "", ch->res_name ? ch->res_name : "", c->name);
if(ch->res_class)
p_delete(&ch->res_class); p_delete(&ch->res_class);
if(ch->res_name)
p_delete(&ch->res_name); p_delete(&ch->res_name);
p_delete(&ch); p_delete(&ch);

View File

@ -75,7 +75,6 @@ iconbox_tell(widget_t *widget, char *property, char *new_value)
if(!a_strcmp(property, "image")) if(!a_strcmp(property, "image"))
{ {
if(d->image)
p_delete(&d->image); p_delete(&d->image);
d->image = a_strdup(new_value); d->image = a_strdup(new_value);
} }