Enlightenment CVS committal

Author  : kiwi
Project : e_modules
Module  : photo

Dir     : e_modules/photo/src/module


Modified Files:
        e_mod_main.c photo_item.c photo_picture.c photo_picture.h 
        photo_picture_local.c 


Log Message:
reduce memory usage
* fix a little leak : need to free the data from edje_data_get
* use evas_stringshare for picture informations

===================================================================
RCS file: /cvs/e/e_modules/photo/src/module/e_mod_main.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- e_mod_main.c        7 Jul 2006 17:15:25 -0000       1.1
+++ e_mod_main.c        7 Jul 2006 18:37:28 -0000       1.2
@@ -233,7 +233,7 @@
 {
    char buf[4096];
    const char *path;
-   const char *version;
+   char *version;
 
    path = e_theme_edje_file_get(PHOTO_THEME_IN_E, PHOTO_THEME_ITEM);
    if (path && path[0])
@@ -241,7 +241,10 @@
         version = edje_file_data_get(path, "version");
         DD(("THEME E path %s version %s", path, version));
         if ( !version || strcmp(version, PHOTO_THEME_VERSION) )
-          return 0;
+          {
+             free(version);
+             return 0;
+          }
         photo->theme = NULL;
      }
    else
@@ -250,9 +253,13 @@
         version = edje_file_data_get(buf, "version");
         DD(("THEME own version %s", version));
         if ( !version || strcmp(version, PHOTO_THEME_VERSION) )
-          return 0;
+          {
+             free(version);
+             return 0;
+          }
         photo->theme = strdup(buf);
      }
+   free(version);
 
    return 1;
 }
===================================================================
RCS file: /cvs/e/e_modules/photo/src/module/photo_item.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- photo_item.c        7 Jul 2006 17:15:25 -0000       1.1
+++ photo_item.c        7 Jul 2006 18:37:28 -0000       1.2
@@ -352,8 +352,8 @@
 {
   Picture *p;
    E_Zone *zone;
-   char *file = NULL;
-   char *name;
+   const char *file = NULL;
+   const char *name;
    char buf[4096];
 
    zone = e_zone_current_get(e_container_current_get(e_manager_current_get()));
@@ -430,7 +430,7 @@
 int  photo_item_action_viewer(Photo_Item *pi)
 {
   Picture *p;
-   char *file = NULL;
+   const char *file = NULL;
    char buf[4096];
 
    p = photo_item_picture_current_get(pi);
===================================================================
RCS file: /cvs/e/e_modules/photo/src/module/photo_picture.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- photo_picture.c     7 Jul 2006 17:15:25 -0000       1.1
+++ photo_picture.c     7 Jul 2006 18:37:28 -0000       1.2
@@ -74,15 +74,15 @@
           }
      }
 
-   if (p->path) free(p->path);
-   if (p->thumb_path) free(p->thumb_path);
+   if (p->path) evas_stringshare_del(p->path);
+   if (p->thumb_path) evas_stringshare_del(p->thumb_path);
    if (p->picture) evas_object_del(p->picture);
 
-   if (p->infos.name) free(p->infos.name);
-   if (p->infos.author) free(p->infos.author);
-   if (p->infos.where_from) free(p->infos.where_from);
-   if (p->infos.date) free(p->infos.date);
-   if (p->infos.comments) free(p->infos.comments);
+   if (p->infos.name) evas_stringshare_del(p->infos.name);
+   if (p->infos.author) evas_stringshare_del(p->infos.author);
+   if (p->infos.where_from) evas_stringshare_del(p->infos.where_from);
+   if (p->infos.date) evas_stringshare_del(p->infos.date);
+   if (p->infos.comments) evas_stringshare_del(p->infos.comments);
 
    photo_picture_histo_picture_del(p);
 
@@ -149,7 +149,7 @@
    return im;
 }
 
-char *photo_picture_name_get(char *url)
+const char *photo_picture_name_get(char *url)
 {
    char buf[4096];
    char *name, *ext;
@@ -170,7 +170,7 @@
    strncpy(buf, name, name_l);
    name[name_l] = '\0';
 
-   return strdup(name);
+   return evas_stringshare_add(name);
 }
 
 char *photo_picture_infos_get(Picture *p)
@@ -206,7 +206,7 @@
    return strdup(buf);
 }
 
-void photo_picture_setbg_add(char *name)
+void photo_picture_setbg_add(const char *name)
 {
    char buf[4096];
    char *home;
===================================================================
RCS file: /cvs/e/e_modules/photo/src/module/photo_picture.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- photo_picture.h     7 Jul 2006 17:15:25 -0000       1.1
+++ photo_picture.h     7 Jul 2006 18:37:28 -0000       1.2
@@ -25,17 +25,17 @@
 {
    Photo_Item *pi;
 
-   char *path;
-   char *thumb_path;
+   const char *path;
+   const char *thumb_path;
    Evas_Object *picture;
 
    struct
    {
-      char *name;
-      char *author;
-      char *where_from;
-      char *date;
-      char *comments;
+      const char *name;
+      const char *author;
+      const char *where_from;
+      const char *date;
+      const char *comments;
    } infos;
    int delete;
    int from;
@@ -62,10 +62,10 @@
 
 int          photo_picture_free(Picture *p, int force, int force_now);
 Evas_Object *photo_picture_object_get(Picture *pic, Evas *evas);
-char        *photo_picture_name_get(char *name);
+const char  *photo_picture_name_get(char *name);
 char        *photo_picture_infos_get(Picture *p);
 
-void         photo_picture_setbg_add(char *name);
+void         photo_picture_setbg_add(const char *name);
 void         photo_picture_setbg_purge(int shutdown);
 
 #endif
===================================================================
RCS file: /cvs/e/e_modules/photo/src/module/photo_picture_local.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- photo_picture_local.c       7 Jul 2006 17:15:25 -0000       1.1
+++ photo_picture_local.c       7 Jul 2006 18:37:28 -0000       1.2
@@ -314,17 +314,19 @@
    DPICL(("File %s loading ...", file));
       
    picture = E_NEW(Picture, 1);
-   picture->path = strdup(file);
-   picture->thumb_path = e_thumb_file_get(picture->path);
+   picture->path = evas_stringshare_add(file);
+   file_tmp = e_thumb_file_get((char *)picture->path);
+   picture->thumb_path = evas_stringshare_add(file_tmp);
+   free(file_tmp);
    picture->infos.name = photo_picture_name_get(name);
    picture->from = PICTURE_LOCAL;
 
    DPICL(("Thumb %s of %s exists ?", picture->thumb_path, picture->path));
-   if (e_thumb_exists(picture->path))
+   if (e_thumb_exists((char *)picture->path))
      {
         int w, h;
 
-        e_thumb_geometry_get(picture->thumb_path, &w, &h, 1);
+        e_thumb_geometry_get((char *)picture->thumb_path, &w, &h, 1);
         DPICL(("THUMB %dx%d (wanted %dx%d)", w, h, th_w, th_h));
         if ((th_w > w) && (th_h > h))
           {
@@ -335,7 +337,7 @@
              DPICL(("File %s thumb exists (%dx%d),  but regen to %dx%d (del 
old %d)", file, w, h, th_w, th_h, i));
              pl->thumb.pictures = evas_list_append(pl->thumb.pictures,
                                                    picture);
-             e_thumb_generate_begin(picture->path, th_w, th_h,
+             e_thumb_generate_begin((char *)picture->path, th_w, th_h,
                                     photo->e_evas,
                                     &picture->picture, _thumb_generate_cb,
                                     picture);
@@ -360,7 +362,7 @@
         DPICL(("File %s thumb doesnt exist, gen %dx%d", file, th_w, th_h));
         pl->thumb.pictures = evas_list_append(pl->thumb.pictures,
                                               picture);
-        e_thumb_generate_begin(picture->path, th_w, th_h,
+        e_thumb_generate_begin((char *)picture->path, th_w, th_h,
                                photo->e_evas,
                                &picture->picture, _thumb_generate_cb,
                                picture);
@@ -628,7 +630,7 @@
 
    if (ecore_file_exists(picture->thumb_path))
      {
-        e_thumb_geometry_get(picture->thumb_path,
+        e_thumb_geometry_get((char *)picture->thumb_path,
                              &picture->original_w, &picture->original_h, 1);
         DPICL(("thumb generated %dx%d", picture->original_w, 
picture->original_h));
 
@@ -693,7 +695,7 @@
         for (l=pl->thumb.pictures; l; l=evas_list_next(l))
           {
              picture = evas_list_data(l);
-             e_thumb_generate_end(picture->path);
+             e_thumb_generate_end((char *)picture->path);
              photo_picture_free(picture, 1, 1);
           }
         evas_list_free(pl->thumb.pictures);



Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to