Enlightenment CVS committal Author : raster Project : e17 Module : libs/evas
Dir : e17/libs/evas/src/lib/canvas Modified Files: evas_object_textblock.c Log Message: use stringshare too =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/evas/src/lib/canvas/evas_object_textblock.c,v retrieving revision 1.118 retrieving revision 1.119 diff -u -3 -r1.118 -r1.119 --- evas_object_textblock.c 26 Nov 2005 08:04:19 -0000 1.118 +++ evas_object_textblock.c 28 Nov 2005 15:30:07 -0000 1.119 @@ -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