Enlightenment CVS committal

Author  : raster
Project : e17
Module  : libs/evas

Dir     : e17/libs/evas/src/lib/canvas


Modified Files:
        evas_font_dir.c evas_object_image.c evas_object_smart.c 
        evas_object_text.c evas_object_textblock.c 


Log Message:


stringshare works! :)

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/evas/src/lib/canvas/evas_font_dir.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -3 -r1.12 -r1.13
--- evas_font_dir.c     29 Nov 2005 09:02:51 -0000      1.12
+++ evas_font_dir.c     30 Nov 2005 08:45:20 -0000      1.13
@@ -36,33 +36,9 @@
 {
    if (!font_dirs) return;
 
-   evas_hash_foreach (font_dirs, font_cache_dir_free, NULL);
-   evas_hash_free (font_dirs);
+   evas_hash_foreach(font_dirs, font_cache_dir_free, NULL);
+   evas_hash_free(font_dirs);
    font_dirs = NULL;
-/*
-   while (fonts_cache)
-     {
-       Fndat *fd;
-
-       fd = evas_list_data(fonts_cache);
-       fonts_cache = evas_list_remove_list(fonts_cache, fonts_cache);
-       if (fd->name) free(fd->name);
-       if (fd->source) free(fd->source);
-       evas->engine.func->font_free(evas->engine.data.output, fd->font);
-       free(fd);
-     }
-   while (fonts_zero)
-     {
-       Fndat *fd;
-
-       fd = evas_list_data(fonts_zero);
-       fonts_zero = evas_list_remove_list(fonts_zero, fonts_zero);
-       if (fd->name) free(fd->name);
-       if (fd->source) free(fd->source);
-       evas->engine.func->font_free(evas->engine.data.output, fd->font);
-       free(fd);
-     }
- */
 }
 
 char *
@@ -94,7 +70,7 @@
    p = strchr(name, ',');
    if (!p)
      {
-       fonts = evas_list_append(fonts, strdup(name));
+       fonts = evas_list_append(fonts, evas_stringshare_add(name));
      }
    else
      {
@@ -104,13 +80,13 @@
        pp = name;
        while (p)
          {
-            nm = malloc(p - pp + 1);
+            nm = alloca(p - pp + 1);
             strncpy(nm, pp, p - pp);
             nm[p - pp] = 0;
-            fonts = evas_list_append(fonts, nm);
+            fonts = evas_list_append(fonts, evas_stringshare_add(nm));
             pp = p + 1;
             p = strchr(pp, ',');
-            if (!p) fonts = evas_list_append(fonts, strdup(pp));
+            if (!p) fonts = evas_list_append(fonts, evas_stringshare_add(pp));
          }
      }
    return fonts;
@@ -145,8 +121,8 @@
        fd = evas_list_data(fonts_zero);
        if (fd->ref != 0) break;
        fonts_zero = evas_list_remove_list(fonts_zero, fonts_zero);
-       if (fd->name) free(fd->name);
-       if (fd->source) free(fd->source);
+       if (fd->name) evas_stringshare_del(fd->name);
+       if (fd->source) evas_stringshare_del(fd->source);
        evas->engine.func->font_free(evas->engine.data.output, fd->font);
        free(fd);
      }
@@ -323,14 +299,14 @@
               }
 #endif
          }
-       free(nm);
+       evas_stringshare_del(nm);
      }
    evas_list_free(fonts);
    fd = calloc(1, sizeof(Fndat));
    if (fd)
      {
-       fd->name = strdup(name);
-       if (source) fd->source = strdup(source);
+       fd->name = evas_stringshare_add(name);
+       if (source) fd->source = evas_stringshare_add(source);
        fd->size = size;
        fd->font = font;
        fd->ref = 1;
@@ -483,7 +459,7 @@
 object_text_font_cache_dir_add(char *dir)
 {
    Evas_Font_Dir *fd;
-   char *tmp;
+   char *tmp, *tmp2;
    Evas_List *fdir;
 
    fd = calloc(1, sizeof(Evas_Font_Dir));
@@ -524,12 +500,13 @@
                         {
                            fn->type = 1;
                            for (i = 0; i < 14; i++)
+                             fn->x.prop[i] = 
evas_stringshare_add(font_prop[i]);
+                           tmp2 = evas_file_path_join(dir, fname);
+                           if (tmp2)
                              {
-                                fn->x.prop[i] = strdup(font_prop[i]);
-                                /* FIXME: what if strdup fails! */
+                                fn->path = evas_stringshare_add(tmp2);
+                                free(tmp2);
                              }
-                           fn->path = evas_file_path_join(dir, fname);
-                           /* FIXME; what is evas_file_path_join fails! */
                            fd->fonts = evas_list_append(fd->fonts, fn);
                         }
                    }
@@ -552,16 +529,20 @@
             fn = calloc(1, sizeof(Evas_Font));
             if (fn)
               {
+                 char *p;
+                 
                  fn->type = 0;
-                 fn->simple.name = strdup(fdir->data);
-                 if (fn->simple.name)
+                 tmp2 = alloca(strlen(fdir->data) + 1);
+                 strcpy(tmp2, fdir->data);
+                 p = strrchr(tmp2, '.');
+                 if (p) *p = 0;
+                 fn->simple.name = evas_stringshare_add(tmp2);
+                 tmp2 = evas_file_path_join(dir, fdir->data);
+                 if (tmp2)
                    {
-                      char *p;
-
-                      p = strrchr(fn->simple.name, '.');
-                      if (p) *p = 0;
+                      fn->path = evas_stringshare_add(tmp2);
+                      free(tmp2);
                    }
-                 fn->path = evas_file_path_join(dir, fdir->data);
                  fd->fonts = evas_list_append(fd->fonts, fn);
               }
             free(tmp);
@@ -591,11 +572,11 @@
                  fa = calloc(1, sizeof(Evas_Font_Alias));
                  if (fa)
                    {
-                      fa->alias = strdup(fname);
+                      fa->alias = evas_stringshare_add(fname);
                       fa->fn = object_text_font_cache_font_find_x(fd, fdef);
                       if ((!fa->alias) || (!fa->fn))
                         {
-                           if (fa->alias) free(fa->alias);
+                           if (fa->alias) evas_stringshare_del(fa->alias);
                            free(fa);
                         }
                       else
@@ -637,10 +618,10 @@
        fd->fonts = evas_list_remove(fd->fonts, fn);
        for (i = 0; i < 14; i++)
          {
-            if (fn->x.prop[i]) free(fn->x.prop[i]);
+            if (fn->x.prop[i]) evas_stringshare_del(fn->x.prop[i]);
          }
-       if (fn->simple.name) free(fn->simple.name);
-       if (fn->path) free(fn->path);
+       if (fn->simple.name) evas_stringshare_del(fn->simple.name);
+       if (fn->path) evas_stringshare_del(fn->path);
        free(fn);
      }
    while (fd->aliases)
@@ -649,7 +630,7 @@
 
        fa = fd->aliases->data;
        fd->aliases = evas_list_remove(fd->aliases, fa);
-       if (fa->alias) free(fa->alias);
+       if (fa->alias) evas_stringshare_del(fa->alias);
        free(fa);
      }
    free(fd);
===================================================================
RCS file: 
/cvsroot/enlightenment/e17/libs/evas/src/lib/canvas/evas_object_image.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -3 -r1.36 -r1.37
--- evas_object_image.c 29 Nov 2005 09:02:51 -0000      1.36
+++ evas_object_image.c 30 Nov 2005 08:45:20 -0000      1.37
@@ -138,11 +138,11 @@
        if ((o->cur.key) && (key) && (!strcmp(o->cur.key, key)))
          return;
      }
-   if (o->cur.file) free(o->cur.file);
-   if (o->cur.key) free(o->cur.key);
-   if (file) o->cur.file = strdup(file);
+   if (o->cur.file) evas_stringshare_del(o->cur.file);
+   if (o->cur.key) evas_stringshare_del(o->cur.key);
+   if (file) o->cur.file = evas_stringshare_add(file);
    else o->cur.file = NULL;
-   if (key) o->cur.key = strdup(key);
+   if (key) o->cur.key = evas_stringshare_add(key);
    else o->cur.key = NULL;
    o->prev.file = NULL;
    o->prev.key = NULL;
@@ -871,20 +871,17 @@
        char *p, *pp;
        char *tflags;
        
-       tflags = strdup(flags);
-       if (tflags)
+       tflags = alloca(strlen(flags) + 1);
+       strcpy(tflags, flags);
+       p = tflags;
+       while (p)
          {
-            p = tflags;
-            while (p)
-              {
-                 pp = strchr(p, ' ');
-                 if (pp) *pp = 0;
-                 sscanf(p, "quality=%i", &quality);
-                 sscanf(p, "compress=%i", &compress);
-                 if (pp) p = pp + 1;
-                 else break;
-              }
-            free(tflags);
+            pp = strchr(p, ' ');
+            if (pp) *pp = 0;
+            sscanf(p, "quality=%i", &quality);
+            sscanf(p, "compress=%i", &compress);
+            if (pp) p = pp + 1;
+            else break;
          }
      }
    im = evas_common_image_new();
@@ -1330,8 +1327,8 @@
    return;
    MAGIC_CHECK_END();
    /* free obj */
-   if (o->cur.file) free(o->cur.file);
-   if (o->cur.key) free(o->cur.key);
+   if (o->cur.file) evas_stringshare_del(o->cur.file);
+   if (o->cur.key) evas_stringshare_del(o->cur.key);
    if (o->engine_data)
      
obj->layer->evas->engine.func->image_free(obj->layer->evas->engine.data.output,
                                               o->engine_data);
@@ -1589,10 +1586,8 @@
      {
        if (((o->cur.file) && (!o->prev.file)) ||
            ((!o->cur.file) && (o->prev.file)) ||
-           (((o->cur.file) && (o->prev.file) && (strcmp(o->cur.file, 
o->prev.file)))) ||
            ((o->cur.key) && (!o->prev.key)) ||
-           ((!o->cur.key) && (o->prev.key)) ||
-           (((o->cur.key) && (o->prev.key) && (strcmp(o->cur.key, 
o->prev.key))))
+           ((!o->cur.key) && (o->prev.key))
            )
          {
             updates = evas_object_render_pre_prev_cur_add(updates, obj);
===================================================================
RCS file: 
/cvsroot/enlightenment/e17/libs/evas/src/lib/canvas/evas_object_smart.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -3 -r1.19 -r1.20
--- evas_object_smart.c 29 Nov 2005 09:02:51 -0000      1.19
+++ evas_object_smart.c 30 Nov 2005 08:45:20 -0000      1.20
@@ -225,7 +225,7 @@
    if (!event) return;
    if (!func) return;
    cb = calloc(1, sizeof(Evas_Smart_Callback));
-   cb->event = strdup(event);
+   cb->event = evas_stringshare_add(event);
    cb->func = func;
    cb->func_data = (void *)data;
    obj->smart.callbacks = evas_list_prepend(obj->smart.callbacks, cb);
@@ -326,7 +326,7 @@
        if (cb->delete_me)
          {
             obj->smart.callbacks = evas_list_remove(obj->smart.callbacks, cb);
-            if (cb->event) free(cb->event);
+            if (cb->event) evas_stringshare_del(cb->event);
             free(cb);
          }
      }
@@ -359,7 +359,7 @@
 
        cb = obj->smart.callbacks->data;
        obj->smart.callbacks = evas_list_remove(obj->smart.callbacks, cb);
-       if (cb->event) free(cb->event);
+       if (cb->event) evas_stringshare_del(cb->event);
        free(cb);
      }
    obj->smart.parent = NULL;
===================================================================
RCS file: 
/cvsroot/enlightenment/e17/libs/evas/src/lib/canvas/evas_object_text.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -3 -r1.48 -r1.49
--- evas_object_text.c  29 Nov 2005 09:02:51 -0000      1.48
+++ evas_object_text.c  30 Nov 2005 08:45:20 -0000      1.49
@@ -108,8 +108,8 @@
    if ((o->cur.source) && (font_source) &&
        (!strcmp(o->cur.source, font_source)))
      return;
-   if (o->cur.source) free(o->cur.source);
-   if (font_source) o->cur.source = strdup(font_source);
+   if (o->cur.source) evas_stringshare_del(o->cur.source);
+   if (font_source) o->cur.source = evas_stringshare_add(font_source);
    else o->cur.source = NULL;
 }
 
@@ -179,8 +179,8 @@
    o->engine_data = evas_font_load(obj->layer->evas, font, o->cur.source, 
size);
    if (!same_font)
      {
-       if (o->cur.font) free(o->cur.font);
-       if (font) o->cur.font = strdup(font);
+       if (o->cur.font) evas_stringshare_del(o->cur.font);
+       if (font) o->cur.font = evas_stringshare_add(font);
        else o->cur.font = NULL;
        o->prev.font = NULL;
      }
@@ -293,8 +293,8 @@
                                       obj->layer->evas->pointer.x,
                                       obj->layer->evas->pointer.y, 1, 1);
    /* DO II */
-   if (o->cur.text) free(o->cur.text);
-   if (text && *text) o->cur.text = strdup(text);
+   if (o->cur.text) evas_stringshare_del(o->cur.text);
+   if ((text) && (*text)) o->cur.text = evas_stringshare_add(text);
    else o->cur.text = NULL;
    o->prev.text = NULL;
    if ((o->engine_data) && (o->cur.text))
@@ -917,7 +917,7 @@
    MAGIC_CHECK_END();
    while (e->font_path)
      {
-       free(e->font_path->data);
+       evas_stringshare_del(e->font_path->data);
        e->font_path = evas_list_remove(e->font_path, e->font_path->data);
      }
 }
@@ -935,7 +935,7 @@
    return;
    MAGIC_CHECK_END();
    if (!path) return;
-   e->font_path = evas_list_append(e->font_path, strdup(path));
+   e->font_path = evas_list_append(e->font_path, evas_stringshare_add(path));
 }
 
 /**
@@ -951,7 +951,7 @@
    return;
    MAGIC_CHECK_END();
    if (!path) return;
-   e->font_path = evas_list_prepend(e->font_path, strdup(path));
+   e->font_path = evas_list_prepend(e->font_path, evas_stringshare_add(path));
 }
 
 /**
@@ -1197,9 +1197,9 @@
    return;
    MAGIC_CHECK_END();
    /* free obj */
-   if (o->cur.text) free(o->cur.text);
-   if (o->cur.font) free(o->cur.font);
-   if (o->cur.source) free(o->cur.source);
+   if (o->cur.text) evas_stringshare_del(o->cur.text);
+   if (o->cur.font) evas_stringshare_del(o->cur.font);
+   if (o->cur.source) evas_stringshare_del(o->cur.source);
    if (o->engine_data) evas_font_free(obj->layer->evas, o->engine_data);
    o->magic = 0;
    free(o);
===================================================================
RCS file: 
/cvsroot/enlightenment/e17/libs/evas/src/lib/canvas/evas_object_textblock.c,v
retrieving revision 1.120
retrieving revision 1.121
diff -u -3 -r1.120 -r1.121
--- evas_object_textblock.c     29 Nov 2005 09:02:51 -0000      1.120
+++ evas_object_textblock.c     30 Nov 2005 08:45:20 -0000      1.121
@@ -329,14 +329,10 @@
        s = ts;
        *alloc = talloc;
      }
-   tbuf = malloc(*len - pos);   
-   if (tbuf)
-     {
-       strncpy(tbuf, s + pos, *len - pos);
-       strncpy(s + pos, s2, l2);   
-       strncpy(s + pos + l2, tbuf, *len - pos);
-       free(tbuf);
-     }
+   tbuf = alloca(*len - pos);   
+   strncpy(tbuf, s + pos, *len - pos);
+   strncpy(s + pos, s2, l2);   
+   strncpy(s + pos + l2, tbuf, *len - pos);
    *len = tlen;
    s[tlen] = 0;
    return s;
@@ -355,10 +351,9 @@
        *alloc = 0;
        return NULL;
      }
-   tbuf = malloc(*len - p2 + 1);
+   tbuf = alloca(*len - p2 + 1);
    strcpy(tbuf, s + p2);
    strcpy(s + p, tbuf);
-   free(tbuf);
    tlen = *len - (p2 - p);
    if (tlen < ((*alloc >> 5) << 15))
      {
@@ -397,9 +392,9 @@
 {
    fmt->ref--;
    if (fmt->ref > 0) return;
-   if (fmt->font.name) free(fmt->font.name);
-   if (fmt->font.fallbacks) free(fmt->font.fallbacks);
-   if (fmt->font.source) free(fmt->font.source);
+   if (fmt->font.name) evas_stringshare_del(fmt->font.name);
+   if (fmt->font.fallbacks) evas_stringshare_del(fmt->font.fallbacks);
+   if (fmt->font.source) evas_stringshare_del(fmt->font.source);
    evas_font_free(obj->layer->evas, fmt->font.font);
    free(fmt);
 }
@@ -423,7 +418,7 @@
        
        fi = (Evas_Object_Textblock_Format_Item *)ln->format_items;
        ln->format_items = evas_object_list_remove(ln->format_items, 
ln->format_items);
-       if (fi->item) free(fi->item);
+       if (fi->item) evas_stringshare_del(fi->item);
        free(fi);
      }
    free(ln);
@@ -705,15 +700,11 @@
      {
        char *ts;
        
-       ts = malloc(p - s + 1);
-       if (ts)
-         {
-            strncpy(ts, s, p - s);
-            ts[p - s] = 0;
-            ts = _clean_white(0, 0, ts);
-            evas_textblock_cursor_text_append(o->cursor, ts);
-            free(ts);
-         }
+       ts = alloca(p - s + 1);
+       strncpy(ts, s, p - s);
+       ts[p - s] = 0;
+       ts = _clean_white(0, 0, ts);
+       evas_textblock_cursor_text_append(o->cursor, ts);
      }
 }
 
@@ -782,8 +773,8 @@
        if ((!fmt->font.name) ||
            ((fmt->font.name) && (strcmp(fmt->font.name, param))))
          {
-            if (fmt->font.name) free(fmt->font.name);
-            fmt->font.name = strdup(param);
+            if (fmt->font.name) evas_stringshare_del(fmt->font.name);
+            fmt->font.name = evas_stringshare_add(param);
             new_font = 1;
          }
      }
@@ -795,8 +786,8 @@
             /* policy - when we say "fallbacks" do we prepend and use prior
              * fallbacks... or shoudl we replace. for nwo we replace
              */
-            if (fmt->font.fallbacks) free(fmt->font.fallbacks);
-            fmt->font.fallbacks = strdup(param);
+            if (fmt->font.fallbacks) evas_stringshare_del(fmt->font.fallbacks);
+            fmt->font.fallbacks = evas_stringshare_add(param);
             new_font = 1;
          }
      }
@@ -816,8 +807,8 @@
        if ((!fmt->font.source) ||
            ((fmt->font.source) && (strcmp(fmt->font.source, param))))
          {
-            if (fmt->font.source) free(fmt->font.source);
-            fmt->font.source = strdup(param);
+            if (fmt->font.source) evas_stringshare_del(fmt->font.source);
+            fmt->font.source = evas_stringshare_add(param);
             new_font = 1;
          }
      }
@@ -867,14 +858,11 @@
          {
             char *ts, *p;
             
-            ts = strdup(param);
-            if (ts)
-              {
-                 p = strchr(ts, '%');
-                 *p = 0;
-                 fmt->halign = ((double)atoi(ts)) / 100.0;
-                 free(ts);
-              }
+            ts = alloca(strlen(param));
+            strcpy(ts, param);
+            p = strchr(ts, '%');
+            *p = 0;
+            fmt->halign = ((double)atoi(ts)) / 100.0;
             if (fmt->halign < 0.0) fmt->halign = 0.0;
             else if (fmt->halign > 1.0) fmt->halign = 1.0;
          }
@@ -897,14 +885,11 @@
          {
             char *ts, *p;
             
-            ts = strdup(param);
-            if (ts)
-              {
-                 p = strchr(ts, '%');
-                 *p = 0;
-                 fmt->valign = ((double)atoi(ts)) / 100.0;
-                 free(ts);
-              }
+            ts = alloca(strlen(param));
+            strcpy(ts, param);
+            p = strchr(ts, '%');
+            *p = 0;
+            fmt->valign = ((double)atoi(ts)) / 100.0;
             if (fmt->valign < 0.0) fmt->valign = 0.0;
             else if (fmt->valign > 1.0) fmt->valign = 1.0;
          }
@@ -1148,9 +1133,9 @@
    fmt2 = calloc(1, sizeof(Evas_Object_Textblock_Format));
    memcpy(fmt2, fmt, sizeof(Evas_Object_Textblock_Format));
    fmt2->ref = 1;
-   if (fmt->font.name) fmt2->font.name = strdup(fmt->font.name);
-   if (fmt->font.fallbacks) fmt2->font.fallbacks = strdup(fmt->font.fallbacks);
-   if (fmt->font.source) fmt2->font.source = strdup(fmt->font.source);
+   if (fmt->font.name) fmt2->font.name = evas_stringshare_add(fmt->font.name);
+   if (fmt->font.fallbacks) fmt2->font.fallbacks = 
evas_stringshare_add(fmt->font.fallbacks);
+   if (fmt->font.source) fmt2->font.source = 
evas_stringshare_add(fmt->font.source);
 
    if ((fmt2->font.name) && (fmt2->font.fallbacks))
      {
@@ -1823,7 +1808,7 @@
    Evas_Object_Textblock_Format_Item *fi;
    
    fi = calloc(1, sizeof(Evas_Object_Textblock_Format_Item));
-   fi->item = strdup(item);
+   fi->item = evas_stringshare_add(item);
    fi->source_node = n;
    c->ln->format_items = evas_object_list_append(c->ln->format_items, fi);
    return fi;




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to