use stringshare! :)

SVN revision: 18728
This commit is contained in:
Carsten Haitzler 2005-11-30 09:56:15 +00:00
parent 8e4c88578a
commit 430b2a1901
7 changed files with 36 additions and 82 deletions

View File

@ -57,7 +57,7 @@ _edje_file_coll_open(Edje_File *edf, Eet_File *ef, char *coll)
free(data);
}
edc->part = strdup(coll);
edc->part = evas_stringshare_add(coll);
edc->references = 1;
edf->collection_hash = evas_hash_add(edf->collection_hash, coll, edc);
return edc;
@ -98,7 +98,7 @@ _edje_file_open(char *file, char *coll, int *error_ret, Edje_Part_Collection **e
return NULL;
}
edf->path = strdup(file);
edf->path = evas_stringshare_add(file);
edf->references = 1;
_edje_textblock_style_parse_and_fix(edf);

View File

@ -279,13 +279,10 @@ _edje_embryo_fn_get_str(Embryo_Program *ep, Embryo_Cell *params)
{
char *ss;
ss = strdup(s);
if (ss)
{
ss[params[3] - 1] = 0;
SETSTR(ss, params[2]);
free(ss);
}
ss = alloca(strlen(s));
strcpy(ss, s);
ss[params[3] - 1] = 0;
SETSTR(ss, params[2]);
}
}
else
@ -505,13 +502,10 @@ _edje_embryo_fn_fetch_str(Embryo_Program *ep, Embryo_Cell *params)
{
char *ss;
ss = strdup(s);
if (ss)
{
ss[params[4] - 1] = 0;
SETSTR(ss, params[3]);
free(ss);
}
ss = alloca(strlen(s));
strcpy(ss, s);
ss[params[4] - 1] = 0;
SETSTR(ss, params[3]);
}
}
else
@ -855,13 +849,10 @@ _edje_embryo_fn_get_state(Embryo_Program *ep, Embryo_Cell *params)
{
char *ss;
ss = strdup(s);
if (ss)
{
ss[params[3] - 1] = 0;
SETSTR(ss, params[2]);
free(ss);
}
ss = alloca(strlen(s));
strcpy(ss, s);
ss[params[3] - 1] = 0;
SETSTR(ss, params[2]);
}
}
else
@ -1033,13 +1024,10 @@ _edje_embryo_fn_get_text(Embryo_Program *ep, Embryo_Cell *params)
{
char *ss;
ss = strdup(s);
if (ss)
{
ss[params[3] - 1] = 0;
SETSTR(ss, params[2]);
free(ss);
}
ss = alloca(strlen(s));
strcpy(ss, s);
ss[params[3] - 1] = 0;
SETSTR(ss, params[2]);
}
}
else

View File

@ -39,18 +39,10 @@ edje_object_file_set(Evas_Object *obj, const char *file, const char *part)
_edje_file_del(ed);
if (ed->path)
{
if (!ed->no_free_path) free(ed->path);
}
if (ed->part)
{
if (!ed->no_free_part) free(ed->part);
}
ed->path = file;
ed->part = part;
// ed->path = strdup(file);
// ed->part = strdup(part);
if (ed->path) evas_stringshare_del(ed->path);
if (ed->part) evas_stringshare_del(ed->part);
ed->path = evas_stringshare_add(file);
ed->part = evas_stringshare_add(part);
ed->load_error = EDJE_LOAD_ERROR_NONE;
_edje_file_add(ed);
@ -145,10 +137,6 @@ edje_object_file_set(Evas_Object *obj, const char *file, const char *part)
if (!rp)
{
ed->load_error = EDJE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
ed->no_free_path = 0;
ed->no_free_part = 0;
ed->path = strdup(ed->path);
ed->part = strdup(ed->part);
return 0;
}
rp->part = ep;
@ -330,25 +318,12 @@ edje_object_file_set(Evas_Object *obj, const char *file, const char *part)
_edje_unref(ed);
ed->load_error = EDJE_LOAD_ERROR_NONE;
_edje_emit(ed, "load", NULL);
ed->path = ed->file->path;
ed->part = ed->collection->part;
ed->no_free_path = 1;
ed->no_free_part = 1;
return 1;
}
else
{
ed->no_free_path = 0;
ed->no_free_part = 0;
ed->path = strdup(ed->path);
ed->part = strdup(ed->part);
return 0;
}
/* we should never get here anyway */
ed->no_free_path = 0;
ed->no_free_part = 0;
ed->path = NULL;
ed->part = NULL;
ed->load_error = EDJE_LOAD_ERROR_NONE;
return 1;
}
@ -573,8 +548,8 @@ _edje_file_del(Edje *ed)
}
if (rp->text.text) free(rp->text.text);
if (rp->text.font) free(rp->text.font);
if (rp->text.cache.in_str) free(rp->text.cache.in_str);
if (rp->text.cache.out_str) free(rp->text.cache.out_str);
if (rp->text.cache.in_str) evas_stringshare_del(rp->text.cache.in_str);
if (rp->text.cache.out_str) evas_stringshare_del(rp->text.cache.out_str);
if (rp->custom.description)
{
@ -692,7 +667,7 @@ _edje_file_free(Edje_File *edf)
evas_hash_foreach(edf->collection_hash, _edje_file_collection_hash_foreach, edf);
evas_hash_free(edf->collection_hash);
}
if (edf->path) free(edf->path);
if (edf->path) evas_stringshare_del(edf->path);
if (edf->compiler) free(edf->compiler);
if (edf->collection_cache) _edje_cache_coll_flush(edf);
_edje_textblock_style_cleanup(edf);
@ -766,8 +741,7 @@ _edje_collection_free(Edje_File *edf, Edje_Part_Collection *ec)
free(edt);
}
}
if (ec->part)
free(ec->part);
if (ec->part) evas_stringshare_del(ec->part);
#ifdef EDJE_PROGRAM_CACHE
if (ec->prog_cache.no_matches) evas_hash_free(ec->prog_cache.no_matches);
if (ec->prog_cache.matches)

View File

@ -82,16 +82,10 @@ _edje_del(Edje *ed)
}
_edje_message_del(ed);
_edje_file_del(ed);
if (ed->path)
{
if (!ed->no_free_path) free(ed->path);
ed->path = NULL;
}
if (ed->part)
{
if (!ed->no_free_part) free(ed->part);
ed->part = NULL;
}
if (ed->path) evas_stringshare_del(ed->path);
if (ed->part) evas_stringshare_del(ed->part);
ed->path = NULL;
ed->part = NULL;
if ((ed->actions) || (ed->pending_actions))
{
_edje_animators = evas_list_remove(_edje_animators, ed);

View File

@ -474,8 +474,6 @@ struct _Edje
unsigned short walking_actions : 1;
unsigned short block_break : 1;
unsigned short delete_me : 1;
unsigned short no_free_path : 1;
unsigned short no_free_part : 1;
double paused_at;
Evas *evas; /* the Evas this Edje belongs to */
Evas_Object *obj; /* the smart object */

View File

@ -364,8 +364,8 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
goto arrange_text;
}
if (ep->text.cache.in_str) free(ep->text.cache.in_str);
ep->text.cache.in_str = strdup(text);
if (ep->text.cache.in_str) evas_stringshare_del(ep->text.cache.in_str);
ep->text.cache.in_str = evas_stringshare_add(text);
ep->text.cache.in_size = size;
if (chosen_desc->text.fit_x)
{
@ -479,8 +479,8 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
&free_text);
}
if (ep->text.cache.out_str) free(ep->text.cache.out_str);
ep->text.cache.out_str = strdup(text);
if (ep->text.cache.out_str) evas_stringshare_del(ep->text.cache.out_str);
ep->text.cache.out_str = evas_stringshare_add(text);
ep->text.cache.in_w = sw;
ep->text.cache.in_h = sh;
ep->text.cache.out_size = size;

View File

@ -308,7 +308,7 @@ edje_text_class_set(const char *text_class, const char *font, Evas_Font_Size siz
Evas_List *members;
Edje_Text_Class *tc;
return;
return; // this is broken right now - need to fix
if (!text_class) return;
if (size < 0) size = 0;
@ -377,7 +377,7 @@ edje_object_text_class_set(Evas_Object *obj, const char *text_class, const char
Evas_List *l;
Edje_Text_Class *tc;
return;
return; // this is broken right now. need to fix
// printf("------------ edje_object_text_class_set\n");
ed = _edje_fetch(obj);
if ((!ed) || (!text_class)) return;