fix memory leaks! no more leaks!

SVN revision: 14934
This commit is contained in:
Carsten Haitzler 2005-05-25 08:08:44 +00:00
parent c56e7f857c
commit f618831ce9
13 changed files with 159 additions and 111 deletions

View File

@ -608,5 +608,5 @@ _e_actions_cb_free(Evas_Hash *hash __UNUSED__, const char *key __UNUSED__,
act = data;
IF_FREE(act->name);
free(act);
return 0;
return 1;
}

View File

@ -295,6 +295,20 @@ e_border_new(E_Container *con, Ecore_X_Window win, int first_map)
bd->client.icccm.fetch.protocol = 1;
bd->client.mwm.fetch.hints = 1;
bd->client.border.changed = 1;
bd->client.netwm.pid = 0;
bd->client.netwm.desktop = 0;
bd->client.netwm.state.modal = 0;
bd->client.netwm.state.sticky = 0;
bd->client.netwm.state.shaded = 0;
bd->client.netwm.state.hidden = 0;
bd->client.netwm.state.maximized_v = 0;
bd->client.netwm.state.maximized_h = 0;
bd->client.netwm.state.skip_taskbar = 0;
bd->client.netwm.state.skip_pager = 0;
bd->client.netwm.state.fullscreen = 0;
bd->client.netwm.state.stacking = E_STACKING_NONE;
bd->client.netwm.type = ECORE_X_WINDOW_TYPE_NORMAL;
bd->client.w = att->w;
bd->client.h = att->h;

View File

@ -62,6 +62,7 @@ e_error_message_manager_show(E_Manager *man, char *title, char *txt)
E_Container *con;
Ecore_X_Window win;
int x, y;
char *s;
con = e_container_current_get(man);
@ -106,7 +107,9 @@ e_error_message_manager_show(E_Manager *man, char *title, char *txt)
maxh = 0;
o = evas_object_image_add(e);
evas_object_image_file_set(o, e_path_find(path_images, "e.png"), NULL);
s = e_path_find(path_images, "e.png");
evas_object_image_file_set(o, s, NULL);
IF_FREE(s);
evas_object_move(o, 16, 16);
evas_object_resize(o, 64, 64);
evas_object_image_fill_set(o, 0, 0, 64, 64);
@ -189,7 +192,9 @@ e_error_message_manager_show(E_Manager *man, char *title, char *txt)
if (error_h > man->h) error_h = man->h;
o = evas_object_image_add(e);
evas_object_image_file_set(o, e_path_find(path_images, "button_out.png"), NULL);
s = e_path_find(path_images, "button_out.png");
evas_object_image_file_set(o, s, NULL);
IF_FREE(s);
evas_object_move(o, (error_w - 64) / 2, error_h - 16 - 32);
evas_object_resize(o, 64, 32);
evas_object_image_fill_set(o, 0, 0, 64, 32);
@ -217,7 +222,9 @@ e_error_message_manager_show(E_Manager *man, char *title, char *txt)
evas_object_show(o);
o = evas_object_image_add(e);
evas_object_image_file_set(o, e_path_find(path_images, "error_bg.png"), NULL);
s = e_path_find(path_images, "error_bg.png");
evas_object_image_file_set(o, s, NULL);
IF_FREE(s);
evas_object_move(o, 0, 0);
evas_object_image_fill_set(o, 0, 0, error_w, error_h);
evas_object_resize(o, error_w, error_h);
@ -362,11 +369,14 @@ _e_error_cb_ok_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Evas_Event_Mouse_Down *ev;
Ecore_Evas *ee;
char *s;
ev = event_info;
if (ev->button != 1) return;
ee = data;
evas_object_image_file_set(obj, e_path_find(path_images, "button_in.png"), NULL);
s = e_path_find(path_images, "button_in.png");
evas_object_image_file_set(obj, s, NULL);
IF_FREE(s);
}
static void
@ -375,11 +385,14 @@ _e_error_cb_ok_up(void *data, Evas *e, Evas_Object *obj, void *event_info)
Evas_Event_Mouse_Up *ev;
Ecore_Evas *ee;
Evas_Object *o;
char *s;
ev = event_info;
if (ev->button != 1) return;
ee = data;
evas_object_image_file_set(obj, e_path_find(path_images, "button_out.png"), NULL);
s = e_path_find(path_images, "button_out.png");
evas_object_image_file_set(obj, s, NULL);
IF_FREE(s);
o = evas_object_name_find(ecore_evas_get(ee), "allocated");
if (o)
{

View File

@ -491,6 +491,7 @@ e_gadman_client_menu_new(E_Gadman_Client *gmc)
E_Menu *m;
E_Menu_Item *mi;
int disallow, seperator;
char *s;
E_OBJECT_CHECK_RETURN(gmc, NULL);
E_OBJECT_TYPE_CHECK_RETURN(gmc, E_GADMAN_CLIENT_TYPE, NULL);
@ -508,24 +509,24 @@ e_gadman_client_menu_new(E_Gadman_Client *gmc)
e_menu_item_label_set(mi, _("Automatic Width"));
e_menu_item_check_set(mi, 1);
e_menu_item_toggle_set(mi, gmc->use_autow);
e_menu_item_icon_edje_set(mi,
e_path_find(path_icons, "default.edj"),
"auto_width");
s = e_path_find(path_icons, "default.edj");
e_menu_item_icon_edje_set(mi, s, "auto_width");
IF_FREE(s);
e_menu_item_callback_set(mi, _e_gadman_cb_auto_width, gmc);
mi = e_menu_item_new(m);
e_menu_item_separator_set(mi, 1);
}
mi = e_menu_item_new(m);
e_menu_item_label_set(mi, _("Half Screen Width"));
e_menu_item_icon_edje_set(mi,
e_path_find(path_icons, "default.edj"),
"half_width");
s = e_path_find(path_icons, "default.edj");
e_menu_item_icon_edje_set(mi, s, "half_width");
IF_FREE(s);
e_menu_item_callback_set(mi, _e_gadman_cb_half_width, gmc);
mi = e_menu_item_new(m);
e_menu_item_label_set(mi, _("Full Screen Width"));
e_menu_item_icon_edje_set(mi,
e_path_find(path_icons, "default.edj"),
"full_width");
s = e_path_find(path_icons, "default.edj");
e_menu_item_icon_edje_set(mi, s, "full_width");
IF_FREE(s);
e_menu_item_callback_set(mi, _e_gadman_cb_full_width, gmc);
}
disallow = (gmc->policy & E_GADMAN_POLICY_EDGES)
@ -535,9 +536,9 @@ e_gadman_client_menu_new(E_Gadman_Client *gmc)
seperator = 1;
mi = e_menu_item_new(m);
e_menu_item_label_set(mi, _("Center Horizontally"));
e_menu_item_icon_edje_set(mi,
e_path_find(path_icons, "default.edj"),
"center_horiz");
s = e_path_find(path_icons, "default.edj");
e_menu_item_icon_edje_set(mi, s, "center_horiz");
IF_FREE(s);
e_menu_item_callback_set(mi, _e_gadman_cb_center_horiz, gmc);
}
if (seperator)
@ -555,24 +556,23 @@ e_gadman_client_menu_new(E_Gadman_Client *gmc)
e_menu_item_label_set(mi, _("Automatic Height"));
e_menu_item_check_set(mi, 1);
e_menu_item_toggle_set(mi, gmc->use_autoh);
e_menu_item_icon_edje_set(mi,
e_path_find(path_icons, "default.edj"),
"auto_height");
s = e_path_find(path_icons, "default.edj"),
e_menu_item_icon_edje_set(mi, s, "auto_height");
IF_FREE(s);
e_menu_item_callback_set(mi, _e_gadman_cb_auto_height, gmc);
mi = e_menu_item_new(m);
e_menu_item_separator_set(mi, 1);
}
mi = e_menu_item_new(m);
e_menu_item_label_set(mi, _("Half Screen Height"));
e_menu_item_icon_edje_set(mi,
e_path_find(path_icons, "default.edj"),
"half_height");
s = e_path_find(path_icons, "default.edj");
e_menu_item_icon_edje_set(mi, s, "half_height");
IF_FREE(s);
e_menu_item_callback_set(mi, _e_gadman_cb_half_height, gmc);
mi = e_menu_item_new(m);
e_menu_item_label_set(mi, _("Full Screen Height"));
e_menu_item_icon_edje_set(mi,
e_path_find(path_icons, "default.edj"),
"full_height");
s = e_path_find(path_icons, "default.edj");
e_menu_item_icon_edje_set(mi, s, "full_height");
e_menu_item_callback_set(mi, _e_gadman_cb_full_height, gmc);
}
disallow = (gmc->policy & E_GADMAN_POLICY_EDGES)
@ -582,9 +582,9 @@ e_gadman_client_menu_new(E_Gadman_Client *gmc)
seperator = 1;
mi = e_menu_item_new(m);
e_menu_item_label_set(mi, _("Center Vertically"));
e_menu_item_icon_edje_set(mi,
e_path_find(path_icons, "default.edj"),
"center_vert");
s = e_path_find(path_icons, "default.edj");
e_menu_item_icon_edje_set(mi, s, "center_vert");
IF_FREE(s);
e_menu_item_callback_set(mi, _e_gadman_cb_center_vert, gmc);
}
if (seperator)

View File

@ -162,7 +162,7 @@ e_hints_client_list_set(void)
ecore_x_netwm_client_list_stacking_set(m->root, 0, NULL);
}
}
IF_FREE(clients);
}
/* Client list is already in stacking order, so this function is nearly
@ -221,7 +221,7 @@ e_hints_client_stacking_set(void)
ecore_x_netwm_client_list_stacking_set(m->root, 0, NULL);
}
}
IF_FREE(clients);
}
void
@ -1033,6 +1033,11 @@ e_hints_window_desktop_set(E_Border *bd)
unsigned int current;
current = (bd->desk->y * bd->zone->desk_x_count) + bd->desk->x;
/* if valgrind complains here it is complaining bd->client.netwm.desktop
* is an uninitialised variable - but it isn't. it can't be. its part of
* a calloc()'d struct and thus has to have been set to 0. hell even
* e_border.c explicitly sets it to 0 on creation of the border object.
*/
if (bd->client.netwm.desktop != current)
{
deskpos[0] = bd->desk->x;

View File

@ -26,6 +26,7 @@ e_init_init(void)
int num;
Evas_Object *o;
Evas_List *l, *screens;
char *s;
num = 0;
roots = ecore_x_window_root_list(&num);
@ -73,18 +74,20 @@ e_init_init(void)
/* first screen */
if (l == screens)
{
edje_object_file_set(o,
/* FIXME: "init.edj" needs to come from config */
e_path_find(path_init, "init.edj"),
"init/splash");
/* FIXME: "init.edj" needs to come from config */
s = e_path_find(path_init, "init.edj"),
edje_object_file_set(o, s, "init/splash");
IF_FREE(s);
_e_init_object = o;
}
/* other screens */
else
edje_object_file_set(o,
/* FIXME: "init.edj" needs to come from config */
e_path_find(path_init, "init.edj"),
"init/extra_screen");
{
/* FIXME: "init.edj" needs to come from config */
s = e_path_find(path_init, "init.edj"),
edje_object_file_set(o, s, "init/extra_screen");
IF_FREE(s);
}
evas_object_move(o, scr->x, scr->y);
evas_object_resize(o, scr->w, scr->h);
evas_object_show(o);
@ -93,10 +96,10 @@ e_init_init(void)
else
{
o = edje_object_add(_e_init_evas);
edje_object_file_set(o,
/* FIXME: "init.edj" needs to come from config */
e_path_find(path_init, "init.edj"),
"init/splash");
/* FIXME: "init.edj" needs to come from config */
s = e_path_find(path_init, "init.edj"),
edje_object_file_set(o, s, "init/splash");
IF_FREE(s);
_e_init_object = o;
evas_object_move(o, 0, 0);
evas_object_resize(o, w, h);

View File

@ -48,6 +48,7 @@ e_int_menus_main_new(void)
E_Menu *m, *subm;
E_Menu_Item *mi;
Main_Data *dat;
char *s;
dat = calloc(1, sizeof(Main_Data));
m = e_menu_new();
@ -59,9 +60,9 @@ e_int_menus_main_new(void)
dat->apps = subm;
mi = e_menu_item_new(m);
e_menu_item_label_set(mi, _("Favorite Applications"));
e_menu_item_icon_edje_set(mi,
e_path_find(path_icons, "default.edj"),
"favorites");
s = e_path_find(path_icons, "default.edj");
e_menu_item_icon_edje_set(mi, s, "favorites");
IF_FREE(s);
e_menu_item_submenu_set(mi, subm);
mi = e_menu_item_new(m);
@ -71,45 +72,45 @@ e_int_menus_main_new(void)
dat->modules = subm;
mi = e_menu_item_new(m);
e_menu_item_label_set(mi, _("Modules"));
e_menu_item_icon_edje_set(mi,
e_path_find(path_icons, "default.edj"),
"module");
s = e_path_find(path_icons, "default.edj");
e_menu_item_icon_edje_set(mi, s, "module");
IF_FREE(s);
e_menu_item_submenu_set(mi, subm);
subm = e_int_menus_desktops_new();
dat->desktops = subm;
mi = e_menu_item_new(m);
e_menu_item_label_set(mi, _("Desktops"));
e_menu_item_icon_edje_set(mi,
e_path_find(path_icons, "default.edj"),
"desktops");
s = e_path_find(path_icons, "default.edj");
e_menu_item_icon_edje_set(mi, s, "desktops");
IF_FREE(s);
e_menu_item_submenu_set(mi, subm);
subm = e_int_menus_clients_new();
dat->clients = subm;
mi = e_menu_item_new(m);
e_menu_item_label_set(mi, _("Windows"));
e_menu_item_icon_edje_set(mi,
e_path_find(path_icons, "default.edj"),
"windows");
s = e_path_find(path_icons, "default.edj");
e_menu_item_icon_edje_set(mi, s, "windows");
IF_FREE(s);
e_menu_item_submenu_set(mi, subm);
subm = e_int_menus_gadgets_new();
dat->gadgets = subm;
mi = e_menu_item_new(m);
e_menu_item_label_set(mi, _("Gadgets"));
e_menu_item_icon_edje_set(mi,
e_path_find(path_icons, "default.edj"),
"gadgets");
s = e_path_find(path_icons, "default.edj");
e_menu_item_icon_edje_set(mi, s, "gadgets");
IF_FREE(s);
e_menu_item_submenu_set(mi, subm);
subm = e_int_menus_themes_new();
dat->themes = subm;
mi = e_menu_item_new(m);
e_menu_item_label_set(mi, _("Themes"));
e_menu_item_icon_edje_set(mi,
e_path_find(path_icons, "default.edj"),
"theme");
s = e_path_find(path_icons, "default.edj");
e_menu_item_icon_edje_set(mi, s, "theme");
IF_FREE(s);
e_menu_item_submenu_set(mi, subm);
mi = e_menu_item_new(m);
@ -117,9 +118,9 @@ e_int_menus_main_new(void)
mi = e_menu_item_new(m);
e_menu_item_label_set(mi, _("About Enlightenment"));
e_menu_item_icon_edje_set(mi,
e_path_find(path_icons, "default.edj"),
"e");
s = e_path_find(path_icons, "default.edj");
e_menu_item_icon_edje_set(mi, s, "e");
IF_FREE(s);
e_menu_item_callback_set(mi, _e_int_menus_main_about, NULL);
mi = e_menu_item_new(m);
@ -127,16 +128,16 @@ e_int_menus_main_new(void)
mi = e_menu_item_new(m);
e_menu_item_label_set(mi, _("Restart Enlightenment"));
e_menu_item_icon_edje_set(mi,
e_path_find(path_icons, "default.edj"),
"reset");
s = e_path_find(path_icons, "default.edj");
e_menu_item_icon_edje_set(mi, s, "reset");
IF_FREE(s);
e_menu_item_callback_set(mi, _e_int_menus_main_restart, NULL);
mi = e_menu_item_new(m);
e_menu_item_label_set(mi, _("Exit Enlightenment"));
e_menu_item_icon_edje_set(mi,
e_path_find(path_icons, "default.edj"),
"power");
s = e_path_find(path_icons, "default.edj");
e_menu_item_icon_edje_set(mi, s, "power");
IF_FREE(s);
e_menu_item_callback_set(mi, _e_int_menus_main_exit, NULL);
return m;
}
@ -454,6 +455,7 @@ _e_int_menus_clients_pre_cb(void *data, E_Menu *m)
Evas_List *l, *borders = NULL;
E_Menu *root;
E_Zone *zone = NULL;
char *s;
e_menu_pre_activate_callback_set(m, NULL, NULL);
root = e_menu_root_get(m);
@ -497,9 +499,9 @@ _e_int_menus_clients_pre_cb(void *data, E_Menu *m)
mi = e_menu_item_new(m);
e_menu_item_label_set(mi, _("Cleanup Windows"));
e_menu_item_icon_edje_set(mi,
e_path_find(path_icons, "default.edj"),
"windows");
s = e_path_find(path_icons, "default.edj");
e_menu_item_icon_edje_set(mi, s, "windows");
IF_FREE(s);
e_menu_item_callback_set(mi, _e_int_menus_clients_cleanup_cb, zone);
e_object_free_attach_func_set(E_OBJECT(m), _e_int_menus_clients_free_hook);
e_object_data_set(E_OBJECT(m), borders);

View File

@ -171,6 +171,7 @@ e_module_new(char *name)
e_config->modules = evas_list_append(e_config->modules, em);
e_config_save_queue();
}
free(modpath);
return m;
}

View File

@ -8,9 +8,6 @@ static void _e_path_free(E_Path *ep);
static void _e_path_cache_free(E_Path *ep);
static Evas_Bool _e_path_cache_free_cb(Evas_Hash *hash, const char *key, void *data, void *fdata);
/* local subsystem globals */
static char _e_path_buf[PATH_MAX] = "";
/* externally accessible functions */
E_Path *
e_path_new(void)
@ -254,18 +251,14 @@ e_path_find(E_Path *ep, const char *file)
{
Evas_List *l;
char *str;
char buf[PATH_MAX] = "";
E_OBJECT_CHECK_RETURN(ep, NULL);
E_OBJECT_TYPE_CHECK_RETURN(ep, E_PATH_TYPE, NULL);
if (!file) return NULL;
_e_path_buf[0] = 0;
str = evas_hash_find(ep->hash, file);
if (str)
{
strcpy(_e_path_buf, str);
return _e_path_buf;
}
if (str) return strdup(str);
/* Look in the default dir list */
for (l = ep->default_dir_list; l; l = l->next)
{
@ -275,17 +268,17 @@ e_path_find(E_Path *ep, const char *file)
epd = l->data;
if (epd->dir)
{
snprintf(_e_path_buf, sizeof(_e_path_buf), "%s/%s", epd->dir, file);
rp = ecore_file_realpath(_e_path_buf);
snprintf(buf, sizeof(buf), "%s/%s", epd->dir, file);
rp = ecore_file_realpath(buf);
if ((rp) && (rp[0] != 0))
{
strncpy(_e_path_buf, rp, sizeof(_e_path_buf) - 1);
_e_path_buf[sizeof(_e_path_buf) - 1] = 0;
strncpy(buf, rp, sizeof(buf) - 1);
buf[sizeof(buf) - 1] = 0;
free(rp);
if (evas_hash_size(ep->hash) >= 512)
_e_path_cache_free(ep);
ep->hash = evas_hash_add(ep->hash, file, strdup(_e_path_buf));
return _e_path_buf;
ep->hash = evas_hash_add(ep->hash, file, strdup(buf));
return strdup(buf);
}
if (rp) free(rp);
}
@ -299,22 +292,22 @@ e_path_find(E_Path *ep, const char *file)
epd = l->data;
if (epd->dir)
{
snprintf(_e_path_buf, sizeof(_e_path_buf), "%s/%s", epd->dir, file);
rp = ecore_file_realpath(_e_path_buf);
snprintf(buf, sizeof(buf), "%s/%s", epd->dir, file);
rp = ecore_file_realpath(buf);
if ((rp) && (rp[0] != 0))
{
strncpy(_e_path_buf, rp, sizeof(_e_path_buf) - 1);
_e_path_buf[sizeof(_e_path_buf) - 1] = 0;
strncpy(buf, rp, sizeof(buf) - 1);
buf[sizeof(buf) - 1] = 0;
free(rp);
if (evas_hash_size(ep->hash) >= 512)
_e_path_cache_free(ep);
ep->hash = evas_hash_add(ep->hash, file, strdup(_e_path_buf));
return _e_path_buf;
ep->hash = evas_hash_add(ep->hash, file, strdup(buf));
return strdup(buf);
}
if (rp) free(rp);
}
}
return _e_path_buf;
return NULL;
}
void
@ -335,7 +328,10 @@ e_path_evas_append(E_Path *ep, Evas *evas)
epd = l->data;
if (epd->dir) evas_font_path_append(evas, epd->dir);
free(epd->dir);
free(epd);
}
if (dir_list) evas_list_free(dir_list);
}
/* compine default_list and and user_list int and easy to use list */
@ -411,5 +407,5 @@ static Evas_Bool
_e_path_cache_free_cb(Evas_Hash *hash __UNUSED__, const char *key __UNUSED__, void *data, void *fdata __UNUSED__)
{
free(data);
return 0;
return 1;
}

View File

@ -11,14 +11,23 @@ e_pointer_container_set(E_Container *con)
int w, h;
Evas_Object *o;
int *pix;
char *s;
E_OBJECT_CHECK(E_OBJECT(con));
o = evas_object_image_add(con->bg_evas);
if (ecore_x_cursor_color_supported_get())
evas_object_image_file_set(o, e_path_find(path_images, "pointer.png"), NULL);
{
s = e_path_find(path_images, "pointer.png");
evas_object_image_file_set(o, s, NULL);
IF_FREE(s);
}
else
evas_object_image_file_set(o, e_path_find(path_images, "pointer_mono.png"), NULL);
{
s = e_path_find(path_images, "pointer_mono.png");
evas_object_image_file_set(o, s, NULL);
IF_FREE(s);
}
evas_object_image_size_get(o, &w, &h);
pix = evas_object_image_data_get(o, 0);
cur = ecore_x_cursor_new(con->win, pix, w, h, 0, 0);
@ -38,14 +47,23 @@ e_pointer_ecore_evas_set(Ecore_Evas *ee)
Evas_Object *o;
int *pix;
Evas *e;
char *s;
e = ecore_evas_get(ee);
win = ecore_evas_software_x11_window_get(ee);
o = evas_object_image_add(e);
if (ecore_x_cursor_color_supported_get())
evas_object_image_file_set(o, e_path_find(path_images, "pointer.png"), NULL);
{
s = e_path_find(path_images, "pointer.png");
evas_object_image_file_set(o, s, NULL);
IF_FREE(s);
}
else
evas_object_image_file_set(o, e_path_find(path_images, "pointer_mono.png"), NULL);
{
s = e_path_find(path_images, "pointer_mono.png");
evas_object_image_file_set(o, s, NULL);
IF_FREE(s);
}
evas_object_image_size_get(o, &w, &h);
pix = evas_object_image_data_get(o, 0);
cur = ecore_x_cursor_new(win, pix, w, h, 0, 0);

View File

@ -104,8 +104,7 @@ e_theme_edje_object_set(Evas_Object *o, char *category, char *group)
if (str[0] != '/')
str = e_path_find(path_themes, str);
/* save cached value */
if (str)
res->cache = strdup(str);
if (str) res->cache = str;
}
if (str)
{
@ -170,8 +169,7 @@ e_theme_edje_file_get(char *category, char *group)
if (str[0] != '/')
str = e_path_find(path_themes, str);
/* save cached value */
if (str)
res->cache = strdup(str);
if (str) res->cache = str;
}
if (str)
{

View File

@ -247,11 +247,7 @@ _cpufreq_free(Cpufreq *e)
_cpufreq_status_free(e->status);
free(e->set_exe_path);
// while (e->conf->faces)
// {
// free(e->conf->faces->data);
// e->conf->faces = evas_list_remove_list(e->conf->faces, e->conf->faces);
// }
evas_list_free(e->conf->faces);
free(e->conf);
free(e);
}

View File

@ -228,6 +228,8 @@ _temperature_free(Temperature *e)
ecore_timer_del(e->temperature_check_timer);
for (l = e->conf->faces; l; l = l->next)
free(l->data);
evas_list_free(e->conf->faces);
free(e->conf);
free(e);