From: Maxime Villard <rustyBSD@gmx.fr>

Subject: [E-devel] [e][PATCH] Optimizations v2
Date: Fri, 21 Dec 2012 22:17:32 +0100

Hi,
same patch as before: removed useless nullchecks and
switched some free()'s to E_FREE().



SVN revision: 81592
This commit is contained in:
Maxime Villard 2012-12-21 21:31:13 +00:00 committed by Mike Blumenkrantz
parent d11c1cc6b1
commit 4a52c46268
23 changed files with 78 additions and 97 deletions

View File

@ -78,8 +78,7 @@ _battery_openbsd_start(void)
void
_battery_openbsd_stop(void)
{
if (ac)
free(ac);
free(ac);
if (bat)
{
eina_stringshare_del(bat->udi);

View File

@ -567,8 +567,7 @@ _e_mod_comp_win_update(E_Comp_Win *cw)
}
if (!_e_mod_comp_win_shaped_check(cw, cw->rects, cw->rects_num))
{
free(cw->rects);
cw->rects = NULL;
E_FREE(cw->rects);
cw->rects_num = 0;
}
if ((cw->rects) && (!cw->shaped))
@ -1941,7 +1940,7 @@ _e_mod_comp_win_add(E_Comp *c,
cw->title = ecore_x_icccm_title_get(cw->win);
if (ecore_x_netwm_name_get(cw->win, &netwm_title))
{
if (cw->title) free(cw->title);
free(cw->title);
cw->title = netwm_title;
}
ecore_x_icccm_name_class_get(cw->win, &cw->name, &cw->clas);
@ -2092,11 +2091,7 @@ _e_mod_comp_win_del(E_Comp_Win *cw)
e_mod_comp_update_free(cw->up);
DBG(" [0x%x] del\n", cw->win);
if (cw->rects)
{
free(cw->rects);
cw->rects = NULL;
}
E_FREE(cw->rects);
if (cw->update_timeout)
{
ecore_timer_del(cw->update_timeout);
@ -2159,10 +2154,10 @@ _e_mod_comp_win_del(E_Comp_Win *cw)
if (cw->inhash)
eina_hash_del(windows, e_util_winid_str_get(cw->win), cw);
if (cw->title) free(cw->title);
if (cw->name) free(cw->name);
if (cw->clas) free(cw->clas);
if (cw->role) free(cw->role);
free(cw->title);
free(cw->name);
free(cw->clas);
free(cw->role);
cw->c->wins_invalid = 1;
cw->c->wins = eina_inlist_remove(cw->c->wins, EINA_INLIST_GET(cw));
pending_count = cw->pending_count;
@ -3836,8 +3831,8 @@ _e_mod_comp_add(E_Manager *man)
ecore_x_sync();
continue;
}
if (wname) free(wname);
if (wclass) free(wclass);
free(wname);
free(wclass);
wname = wclass = NULL;
cw = _e_mod_comp_win_add(c, wins[i]);
if (!cw) continue;

View File

@ -28,7 +28,7 @@ e_mod_comp_update_new(void)
void
e_mod_comp_update_free(E_Update *up)
{
if (up->tiles) free(up->tiles);
free(up->tiles);
free(up);
}

View File

@ -414,7 +414,7 @@ _e_mod_comp_wl_shell_surface_set_title(struct wl_client *client, struct wl_resou
LOGFN(__FILE__, __LINE__, __FUNCTION__);
wss = resource->data;
if (wss->title) free(wss->title);
free(wss->title);
wss->title = strdup(title);
}
@ -426,7 +426,7 @@ _e_mod_comp_wl_shell_surface_set_class(struct wl_client *client, struct wl_resou
LOGFN(__FILE__, __LINE__, __FUNCTION__);
wss = resource->data;
if (wss->clas) free(wss->clas);
free(wss->clas);
wss->clas = strdup(clas);
}

View File

@ -206,10 +206,10 @@ _match_free(Match_Config *m)
if (m->match.clas) eina_stringshare_del(m->match.clas);
if (m->match.role) eina_stringshare_del(m->match.role);
if (m->match.shadow_style) eina_stringshare_del(m->match.shadow_style);
if (m->title) free(m->title);
if (m->name) free(m->name);
if (m->clas) free(m->clas);
if (m->role) free(m->role);
free(m->title);
free(m->name);
free(m->clas);
free(m->role);
free(m);
}
@ -615,32 +615,28 @@ _edit_ok(void *d1,
if (m->title)
{
if (m->title[0]) m->match.title = eina_stringshare_add(m->title);
free(m->title);
m->title = NULL;
E_FREE(m->title);
}
if (m->match.name) eina_stringshare_del(m->match.name);
m->match.name = NULL;
if (m->name)
{
if (m->name[0]) m->match.name = eina_stringshare_add(m->name);
free(m->name);
m->name = NULL;
E_FREE(m->name);
}
if (m->match.clas) eina_stringshare_del(m->match.clas);
m->match.clas = NULL;
if (m->clas)
{
if (m->clas[0]) m->match.clas = eina_stringshare_add(m->clas);
free(m->clas);
m->clas = NULL;
E_FREE(m->clas);
}
if (m->match.role) eina_stringshare_del(m->match.role);
m->match.role = NULL;
if (m->role)
{
if (m->role[0]) m->match.role = eina_stringshare_add(m->role);
free(m->role);
m->role = NULL;
E_FREE(m->role);
}
m->match.borderless = m->borderless;
m->match.dialog = m->dialog;

View File

@ -126,11 +126,9 @@ _free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
if (cfdata->hdl)
ecore_event_handler_del(cfdata->hdl);
eina_stringshare_del(cfdata->bg);
if (cfdata->name)
E_FREE(cfdata->name);
E_FREE(cfdata->name);
#if (ECORE_VERSION_MAJOR > 1) || (ECORE_VERSION_MINOR >= 8)
if (cfdata->profile)
E_FREE(cfdata->profile);
E_FREE(cfdata->profile);
#endif
E_FREE(cfdata);
}

View File

@ -178,7 +178,7 @@ _free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
eina_stringshare_del(cfdata->locals.binding);
eina_stringshare_del(cfdata->locals.action);
if (cfdata->locals.params) free(cfdata->locals.params);
free(cfdata->locals.params);
E_FREE(cfdata);
}
@ -644,7 +644,7 @@ _update_action_list(E_Config_Dialog_Data *cfdata)
else
{
e_widget_ilist_unselect(cfdata->gui.o_action_list);
if (cfdata->locals.action) free(cfdata->locals.action);
free(cfdata->locals.action);
cfdata->locals.action = strdup("");
e_widget_entry_clear(cfdata->gui.o_params);
}
@ -924,7 +924,7 @@ _edge_grab_wnd_show(E_Config_Dialog_Data *cfdata)
{
label = _edge_binding_text_get(cfdata->locals.edge, ((float)cfdata->locals.delay), cfdata->locals.modifiers);
edje_object_part_text_set(cfdata->gui.o_selector, "e.text.selection", label);
if (label) E_FREE(label);
E_FREE(label);
}
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
@ -971,7 +971,7 @@ _edge_grab_wnd_slider_changed_cb(void *data, Evas_Object *obj __UNUSED__)
((float)cfdata->locals.delay),
cfdata->locals.modifiers);
edje_object_part_text_set(cfdata->gui.o_selector, "e.text.selection", label);
if (label) E_FREE(label);
E_FREE(label);
}
static void
@ -994,7 +994,7 @@ _edge_grab_wnd_check_changed_cb(void *data, Evas_Object *obj __UNUSED__)
}
edje_object_part_text_set(cfdata->gui.o_selector, "e.text.selection", label);
if (label) E_FREE(label);
E_FREE(label);
}
static void
@ -1078,7 +1078,7 @@ stop:
cfdata->locals.click ? (-1.0 * cfdata->locals.button) : ((float)cfdata->locals.delay),
cfdata->locals.modifiers);
edje_object_part_text_set(cfdata->gui.o_selector, "e.text.selection", label);
if (label) E_FREE(label);
E_FREE(label);
}
static void

View File

@ -175,8 +175,8 @@ _free_data(E_Config_Dialog *cfd __UNUSED__,
eina_stringshare_del(cfdata->locals.binding);
eina_stringshare_del(cfdata->locals.action);
if (cfdata->locals.params) free(cfdata->locals.params);
if (cfdata->params) free(cfdata->params);
free(cfdata->locals.params);
free(cfdata->params);
E_FREE(cfdata);
}
@ -785,7 +785,7 @@ _update_action_list(E_Config_Dialog_Data *cfdata)
else
{
e_widget_ilist_unselect(cfdata->gui.o_action_list);
if (cfdata->locals.action) free(cfdata->locals.action);
free(cfdata->locals.action);
cfdata->locals.action = strdup("");
e_widget_entry_clear(cfdata->gui.o_params);
}

View File

@ -191,7 +191,7 @@ _free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
eina_stringshare_del(cfdata->locals.action);
eina_stringshare_del(cfdata->locals.cur);
if (cfdata->locals.params) free(cfdata->locals.params);
free(cfdata->locals.params);
E_FREE(cfdata);
}
@ -756,8 +756,8 @@ _update_mouse_binding_list(E_Config_Dialog_Data *cfdata)
snprintf(label, sizeof(label), "%s + %s", button ? button : "", mods);
else
snprintf(label, sizeof(label), "%s", button ? button : "");
if (button) free(button);
if (mods) free(mods);
free(button);
free(mods);
switch (eb->button)
{
@ -817,8 +817,8 @@ _update_mouse_binding_list(E_Config_Dialog_Data *cfdata)
snprintf(label, sizeof(label), "%s + %s", button ? button : "", mods);
else
snprintf(label, sizeof(label), "%s", button ? button : "");
if (button) free(button);
if (mods) free(mods);
free(button);
free(mods);
snprintf(val, sizeof(val), "w%d", i);

View File

@ -233,8 +233,8 @@ _create_menus_list(Evas *evas, E_Config_Dialog_Data *cfdata)
}
}
e_widget_ilist_append(ob, NULL, label, NULL, NULL, file);
if (tlabel) free(tlabel);
if (tdesc) free(tdesc);
free(tlabel);
free(tdesc);
free(file);
i++;
}

View File

@ -77,8 +77,8 @@ _free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
if (evr->val) eina_stringshare_del(evr->val);
E_FREE(evr);
}
if (cfdata->var_str) free(cfdata->var_str);
if (cfdata->val_str) free(cfdata->val_str);
free(cfdata->var_str);
free(cfdata->val_str);
E_FREE(cfdata);
}

View File

@ -498,7 +498,7 @@ e_smart_monitor_changes_apply(Evas_Object *obj)
noutputs, mx, my,
sd->current.mode->xid,
sd->current.orientation);
if (outputs) free(outputs);
free(outputs);
}
}
else

View File

@ -691,7 +691,7 @@ _pan_sel(Evas_Object *obj, Item *it)
if (it2->selected) it2->selected = 0;
}
it->selected = EINA_TRUE;
if (sd->info->bg_file) free(sd->info->bg_file);
free(sd->info->bg_file);
evas_object_hide(sd->info->mini);
if (it->file)
{
@ -710,7 +710,7 @@ _pan_sel(Evas_Object *obj, Item *it)
if (p) *p = 0;
}
edje_object_part_text_set(sd->info->bg, "e.text.filename", name);
if (name) free(name);
free(name);
}
else
{
@ -947,7 +947,7 @@ _pan_file_add(Evas_Object *obj, const char *file, Eina_Bool remote, Eina_Bool th
if (p) *p = 0;
}
edje_object_part_text_set(sd->info->bg, "e.text.filename", name);
if (name) free(name);
free(name);
}
}
}
@ -1074,8 +1074,7 @@ _idler(void *data)
}
if (!eina_iterator_next(info->dir, (void**) &st))
{
free(info->curdir);
info->curdir = NULL;
E_FREE(info->curdir);
eina_iterator_free(info->dir);
info->dir = NULL;
info->idler = NULL;
@ -1108,7 +1107,7 @@ _scan(Info *info)
edje_object_part_text_set(info->bg, "e.text.busy_label",
_("Loading files..."));
}
if (info->curdir) free(info->curdir);
free(info->curdir);
info->curdir = info->dirs->data;
info->dirs = eina_list_remove_list(info->dirs, info->dirs);
if (!info->dir) info->dir = eina_file_stat_ls(info->curdir);
@ -1162,8 +1161,7 @@ wp_browser_new(E_Container *con)
win = e_win_new(con);
if (!win)
{
free(info);
info = NULL;
E_FREE(info);
return NULL;
}
info->win = win;
@ -1328,8 +1326,7 @@ wp_broser_free(Info *info)
free(s);
if (info->idler) ecore_idler_del(info->idler);
// del other stuff
free(info);
info = NULL;
E_FREE(info);
}
E_Config_Dialog *

View File

@ -550,7 +550,7 @@ _cpufreq_status_free(Status *s)
free(l->data);
eina_list_free(s->governors);
}
if (s->cur_governor) free(s->cur_governor);
free(s->cur_governor);
if (s->orig_governor) eina_stringshare_del(s->orig_governor);
free(s);
}
@ -834,7 +834,7 @@ _cpufreq_status_check_current(Status *s)
{
ret = 1;
if (s->cur_governor) free(s->cur_governor);
free(s->cur_governor);
s->cur_governor = strdup(buf);
for (i = strlen(s->cur_governor) - 1; i >= 0; i--)

View File

@ -212,8 +212,8 @@ _ds_shutdown(Dropshadow *ds)
_ds_shadow_del(sh);
}
if (ds->idler_before) e_main_idler_before_del(ds->idler_before);
if (ds->table.gauss) free(ds->table.gauss);
if (ds->table.gauss2) free(ds->table.gauss2);
free(ds->table.gauss);
free(ds->table.gauss2);
_ds_shared_free(ds);
free(ds);
}
@ -1083,7 +1083,7 @@ _ds_blur_init(Dropshadow *ds)
{
int i;
if (ds->table.gauss) free(ds->table.gauss);
free(ds->table.gauss);
ds->table.gauss_size = (ds->conf->blur_size * 2) - 1;
ds->table.gauss = calloc(1, ds->table.gauss_size * sizeof(unsigned char));
@ -1098,7 +1098,7 @@ _ds_blur_init(Dropshadow *ds)
_ds_gauss_int(-1.5 + (v * 3.0)) * 255.0;
}
if (ds->table.gauss2) free(ds->table.gauss2);
free(ds->table.gauss2);
ds->table.gauss2_size = (ds->conf->blur_size * 2) - 1;
ds->table.gauss2 = calloc(1, ds->table.gauss2_size * sizeof(unsigned char));
@ -1484,7 +1484,7 @@ static void
_ds_shpix_free(Shpix *sp)
{
if (!sp) return;
if (sp->pix) free(sp->pix);
free(sp->pix);
free(sp);
}
@ -1968,8 +1968,7 @@ _tilebuf_intersect(int tsize, int tlen, int tnum, int x, int w, int *x1, int *x2
static void
_tilebuf_setup(Tilebuf *tb)
{
if (tb->tiles.tiles) free(tb->tiles.tiles);
tb->tiles.tiles = NULL;
E_FREE(tb->tiles.tiles);
tb->tiles.w = (tb->outbuf_w + (tb->tile_size.w - 1)) / tb->tile_size.w;
tb->tiles.h = (tb->outbuf_h + (tb->tile_size.h - 1)) / tb->tile_size.h;
@ -2004,7 +2003,7 @@ _tilebuf_new(int w, int h)
static void
_tilebuf_free(Tilebuf *tb)
{
if (tb->tiles.tiles) free(tb->tiles.tiles);
free(tb->tiles.tiles);
free(tb);
}

View File

@ -1262,9 +1262,7 @@ _plugins_shutdown(void)
_dir_monitor_free();
if (current_path)
free(current_path);
current_path = NULL;
E_FREE(current_path);
}
/***************************************************************************/

View File

@ -356,7 +356,7 @@ _il_home_desktop_find_border(E_Zone *zone, Efreet_Desktop *desktop)
if (e_exec_startup_id_pid_find(bd->client.netwm.pid,
bd->client.netwm.startup_id) == desktop)
{
if (exe) free(exe);
free(exe);
return bd;
}
if (exe)
@ -381,7 +381,7 @@ _il_home_desktop_find_border(E_Zone *zone, Efreet_Desktop *desktop)
}
}
}
if (exe) free(exe);
free(exe);
return NULL;
}

View File

@ -415,7 +415,7 @@ e_kbd_dict_save(E_Kbd_Dict *kd)
else
fprintf(f, "%s %i\n", wd, usage);
}
if (wd) free(wd);
free(wd);
p = pn;
if (p >= (kd->file.dict + kd->file.size)) break;
}
@ -585,7 +585,7 @@ e_kbd_dict_word_usage_adjust(E_Kbd_Dict *kd, const char *word, int adjust)
// FIXME: we need to find an EXACT line match - case and all
wd = _e_kbd_dict_line_parse(kd, line, &usage);
if (wd) free(wd);
free(wd);
}
usage += adjust;
_e_kbd_dict_changed_write_add(kd, word, usage);

View File

@ -124,9 +124,9 @@ _e_kbd_int_layout_buf_update(E_Kbd_Int *ki)
s3 = strdup(_e_kbd_int_str_unquote(out_capslock));
e_kbd_buf_layout_key_add(ki->kbuf, s1, s2, s3,
ky->x, ky->y, ky->w, ky->h);
if (s1) free(s1);
if (s2) free(s2);
if (s3) free(s3);
free(s1);
free(s2);
free(s3);
}
}
}
@ -913,7 +913,7 @@ _e_kbd_int_layout_free(E_Kbd_Int *ki)
{
E_Kbd_Int_Key *ky;
if (ki->layout.directory) free(ki->layout.directory);
free(ki->layout.directory);
if (ki->layout.file) eina_stringshare_del(ki->layout.file);
ki->layout.directory = NULL;
ki->layout.file = NULL;
@ -999,8 +999,7 @@ _e_kbd_int_layout_parse(E_Kbd_Int *ki, const char *layout)
if (!ky) continue;
if (sscanf(buf, "%*s %i %i %i %i\n", &(ky->x), &(ky->orig_y), &(ky->w), &(ky->orig_h)) != 4)
{
free(ky);
ky = NULL;
E_FREE(ky);
continue;
}
ki->layout.keys = eina_list_append(ki->layout.keys, ky);

View File

@ -153,7 +153,7 @@ _e_mod_illume_config_policy_policies_get(void)
e_object_del(E_OBJECT(p));
continue;
}
if (file) free(file);
free(file);
l = eina_list_append(l, p);
}

View File

@ -46,7 +46,7 @@ e_mod_policy_init(void)
{
/* loading policy failed, bail out */
printf("Cannot load policy: %s\n", file);
if (file) free(file);
free(file);
return 0;
}
@ -493,7 +493,7 @@ _e_mod_policy_cb_policy_change(void *data __UNUSED__, int type, void *event __UN
/* try to load the policy */
_e_mod_policy_load(file);
if (file) free(file);
free(file);
return ECORE_CALLBACK_PASS_ON;
}

View File

@ -134,9 +134,9 @@ _e_mod_illume_config_select_window_list_changed(void *data)
break;
}
if (title) free(title);
if (name) free(name);
if (class) free(class);
free(title);
free(name);
free(class);
if (_sw_change_timer) ecore_timer_del(_sw_change_timer);
_sw_change_timer =
@ -235,9 +235,9 @@ _e_mod_illume_config_select_window_match(E_Border *bd)
break;
}
if (title) free(title);
if (name) free(name);
if (class) free(class);
free(title);
free(name);
free(class);
return match;
}

View File

@ -484,7 +484,7 @@ _win_share_cb(void *data __UNUSED__, void *data2 __UNUSED__)
return;
}
rewind(f);
if (fdata) free(fdata);
free(fdata);
fdata = malloc(fsize);
if (!fdata)
{