From 59ebbdeee0a29dc642777c391aceb823d162b478 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Wed, 29 Jun 2011 13:58:42 +0000 Subject: [PATCH] emotion: use stringshare for file. SVN revision: 60818 --- legacy/emotion/src/lib/emotion_smart.c | 29 ++++++++++++++++++-------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/legacy/emotion/src/lib/emotion_smart.c b/legacy/emotion/src/lib/emotion_smart.c index 7cfe946d49..c9451d30de 100644 --- a/legacy/emotion/src/lib/emotion_smart.c +++ b/legacy/emotion/src/lib/emotion_smart.c @@ -1,6 +1,14 @@ #include "emotion_private.h" #include "Emotion.h" +#ifdef HAVE_EIO +# include +#else +# ifdef HAVE_XATTR +# include +# endif +#endif + #define E_SMART_OBJ_GET(smart, o, type) \ { \ char *_e_smart_str; \ @@ -42,7 +50,7 @@ struct _Smart_Data char *module_name; - char *file; + const char *file; Evas_Object *obj; double ratio; double pos; @@ -69,6 +77,11 @@ struct _Smart_Data int button; } spu; +#ifdef HAVE_EIO + Eio_File *load_xattr; + Eio_File *save_xattr; +#endif + Emotion_Module_Options module_options; }; @@ -275,7 +288,7 @@ EAPI Eina_Bool emotion_object_init(Evas_Object *obj, const char *module_filename) { Smart_Data *sd; - char *file; + const char *file; E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0); @@ -317,7 +330,7 @@ emotion_object_init(Evas_Object *obj, const char *module_filename) if (file) { emotion_object_file_set(obj, file); - free(file); + eina_stringshare_del(file); } return EINA_TRUE; @@ -333,13 +346,12 @@ emotion_object_file_set(Evas_Object *obj, const char *file) DBG("file=%s", file); if (!sd->module) return EINA_FALSE; - if ((file) && (sd->file) && (!strcmp(file, sd->file))) return EINA_FALSE; + if ((file) && (sd->file) && (file == sd->file || !strcmp(file, sd->file))) return EINA_FALSE; if ((file) && (file[0] != 0)) { int w, h; - free(sd->file); - sd->file = strdup(file); + eina_stringshare_replace(&sd->file, file); sd->module->file_close(sd->video); evas_object_image_data_set(sd->obj, NULL); evas_object_image_size_set(sd->obj, 1, 1); @@ -361,8 +373,7 @@ emotion_object_file_set(Evas_Object *obj, const char *file) evas_object_image_size_set(sd->obj, 1, 1); _emotion_image_data_zero(sd->obj); } - free(sd->file); - sd->file = NULL; + eina_stringshare_replace(&sd->file, NULL); } return EINA_TRUE; @@ -1597,7 +1608,7 @@ _smart_del(Evas_Object * obj) if (sd->video) sd->module->file_close(sd->video); _emotion_module_close(sd->module, sd->video); evas_object_del(sd->obj); - free(sd->file); + eina_stringshare_del(sd->file); free(sd->module_name); if (sd->job) ecore_job_del(sd->job); free(sd->progress.info);