[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

@ -1140,28 +1140,29 @@ handle_kpress(xcb_key_press_event_t *e)
#ifndef HAVE_GETLINE
static int
getline(char ** buf, size_t* len, FILE* in)
getline(char **buf, size_t *len, FILE* in)
{
int i;
if (*buf) {
if (*buf)
p_delete(buf);
(*buf) = NULL;
}
if (*len)
*len = 0;
do {
do
{
p_realloc(buf, *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();
if ((*buf)[*len - 10 + i] == '\n' ||
(*buf)[*len - 10 + i] == '\r') {
if ((*buf)[*len - 10 + i] == '\n'
|| (*buf)[*len - 10 + i] == '\r')
return (*len - 10 + i + 1);
}
}
}
while(!feof(in));
return -1;
}
#endif
@ -1195,7 +1196,6 @@ item_list_fill_stdin(void)
}
while((line_len = getline(&buf, &len, stdin)) != -1);
if(buf)
p_delete(&buf);
return has_entry;

View File

@ -128,7 +128,6 @@ scan()
!(attr_r->map_state == XCB_MAP_STATE_VIEWABLE ||
window_getstate(wins[i]) == XCB_WM_ICONIC_STATE))
{
if(attr_r)
p_delete(&attr_r);
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)
p_delete(&prop_r);
return false;
}
@ -143,9 +142,7 @@ xutil_get_transient_for_hint(xcb_connection_t *c, xcb_window_t win,
t_hint_r->length == 0)
{
*prop_win = XCB_NONE;
if(t_hint_r)
p_delete(&t_hint_r);
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 ||
class_hint_r->format != 8)
{
if(class_hint_r)
p_delete(&class_hint_r);
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 ||
!(data = (uint32_t *) xcb_get_property_value(r)))
{
if(r)
p_delete(&r);
return NULL;
}

View File

@ -71,9 +71,7 @@ rule_matching_client(client_t *c)
snprintf(prop, len, "%s:%s:%s",
ch->res_class ? ch->res_class : "", ch->res_name ? ch->res_name : "", c->name);
if(ch->res_class)
p_delete(&ch->res_class);
if(ch->res_name)
p_delete(&ch->res_name);
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(d->image)
p_delete(&d->image);
d->image = a_strdup(new_value);
}