[awesome] Remove checking for value before p_delete()'ing memory
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
a3a47d718e
commit
dc27cff8ab
|
@ -1140,28 +1140,29 @@ handle_kpress(xcb_key_press_event_t *e)
|
||||||
|
|
||||||
#ifndef HAVE_GETLINE
|
#ifndef HAVE_GETLINE
|
||||||
static int
|
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,8 +1196,7 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,8 +128,7 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,8 +57,7 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
4
ewmh.c
4
ewmh.c
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
6
rules.c
6
rules.c
|
@ -71,10 +71,8 @@ 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);
|
p_delete(&ch->res_name);
|
||||||
if(ch->res_name)
|
|
||||||
p_delete(&ch->res_name);
|
|
||||||
p_delete(&ch);
|
p_delete(&ch);
|
||||||
|
|
||||||
for(r = globalconf.rules; r; r = r->next)
|
for(r = globalconf.rules; r; r = r->next)
|
||||||
|
|
|
@ -75,8 +75,7 @@ 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);
|
||||||
}
|
}
|
||||||
else if(!a_strcmp(property, "resize"))
|
else if(!a_strcmp(property, "resize"))
|
||||||
|
|
Loading…
Reference in New Issue