parent
1c2dc52ae0
commit
3621124677
|
@ -36,33 +36,9 @@ evas_font_dir_cache_free(void)
|
|||
{
|
||||
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 @@ evas_font_set_get(const char *name)
|
|||
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 @@ evas_font_set_get(const char *name)
|
|||
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 @@ evas_font_free(Evas *evas, void *font)
|
|||
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 @@ evas_font_load(Evas *evas, const char *name, const char *source, int size)
|
|||
}
|
||||
#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 @@ static Evas_Font_Dir *
|
|||
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 @@ object_text_font_cache_dir_add(char *dir)
|
|||
{
|
||||
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 @@ object_text_font_cache_dir_add(char *dir)
|
|||
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 @@ object_text_font_cache_dir_add(char *dir)
|
|||
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 @@ object_text_font_cache_dir_del(char *dir, Evas_Font_Dir *fd)
|
|||
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 @@ object_text_font_cache_dir_del(char *dir, Evas_Font_Dir *fd)
|
|||
|
||||
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);
|
||||
|
|
|
@ -138,11 +138,11 @@ evas_object_image_file_set(Evas_Object *obj, const char *file, const char *key)
|
|||
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 @@ evas_object_image_save(Evas_Object *obj, const char *file, const char *key, cons
|
|||
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 @@ evas_object_image_free(Evas_Object *obj)
|
|||
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 @@ evas_object_image_render_pre(Evas_Object *obj)
|
|||
{
|
||||
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);
|
||||
|
|
|
@ -225,7 +225,7 @@ evas_object_smart_callback_add(Evas_Object *obj, const char *event, void (*func)
|
|||
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 @@ evas_object_smart_callbacks_clear(Evas_Object *obj)
|
|||
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 @@ evas_object_smart_cleanup(Evas_Object *obj)
|
|||
|
||||
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;
|
||||
|
|
|
@ -108,8 +108,8 @@ evas_object_text_font_source_set(Evas_Object *obj, const char *font_source)
|
|||
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 @@ evas_object_text_font_set(Evas_Object *obj, const char *font, Evas_Font_Size siz
|
|||
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 @@ evas_object_text_text_set(Evas_Object *obj, const char *text)
|
|||
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 @@ evas_font_path_clear(Evas *e)
|
|||
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 @@ evas_font_path_append(Evas *e, const char *path)
|
|||
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 @@ evas_font_path_prepend(Evas *e, const char *path)
|
|||
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 @@ evas_object_text_free(Evas_Object *obj)
|
|||
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);
|
||||
|
|
|
@ -329,14 +329,10 @@ _strbuf_insert(char *s, char *s2, int pos, int *len, int *alloc)
|
|||
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 @@ _strbuf_remove(char *s, int p, int p2, int *len, int *alloc)
|
|||
*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 @@ _format_free(Evas_Object *obj, Evas_Object_Textblock_Format *fmt)
|
|||
{
|
||||
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 @@ _line_free(Evas_Object *obj, Evas_Object_Textblock_Line *ln)
|
|||
|
||||
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 @@ _append_text_run(Evas_Object_Textblock *o, char *s, char *p)
|
|||
{
|
||||
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 @@ _format_command(Evas_Object *obj, Evas_Object_Textblock_Format *fmt, char *cmd,
|
|||
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 @@ _format_command(Evas_Object *obj, Evas_Object_Textblock_Format *fmt, char *cmd,
|
|||
/* 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 @@ _format_command(Evas_Object *obj, Evas_Object_Textblock_Format *fmt, char *cmd,
|
|||
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 @@ _format_command(Evas_Object *obj, Evas_Object_Textblock_Format *fmt, char *cmd,
|
|||
{
|
||||
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 @@ _format_command(Evas_Object *obj, Evas_Object_Textblock_Format *fmt, char *cmd,
|
|||
{
|
||||
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 @@ _format_dup(Evas_Object *obj, Evas_Object_Textblock_Format *fmt)
|
|||
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 @@ _layout_format_item_add(Ctxt *c, Evas_Object_Textblock_Node *n, char *item)
|
|||
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;
|
||||
|
|
|
@ -11,8 +11,8 @@ struct _Evas_Stringshare
|
|||
|
||||
struct _Evas_Stringshare_El
|
||||
{
|
||||
int references;
|
||||
Evas_Stringshare_El *next, *prev;
|
||||
int references;
|
||||
};
|
||||
|
||||
static inline int _evas_stringshare_hash_gen(const char *str);
|
||||
|
@ -73,6 +73,7 @@ evas_stringshare_add(const char *str)
|
|||
if (el->next) el->next->prev = el->prev;
|
||||
el->prev = NULL;
|
||||
el->next = share.buckets[hash_num];
|
||||
el->next->prev = el;
|
||||
share.buckets[hash_num] = el;
|
||||
}
|
||||
el->references++;
|
||||
|
@ -85,6 +86,7 @@ evas_stringshare_add(const char *str)
|
|||
el->references = 1;
|
||||
el->prev = NULL;
|
||||
el->next = share.buckets[hash_num];
|
||||
if (el->next) el->next->prev = el;
|
||||
share.buckets[hash_num] = el;
|
||||
return el_str;
|
||||
}
|
||||
|
@ -108,7 +110,6 @@ evas_stringshare_del(const char *str)
|
|||
if (el->next) el->next->prev = el->prev;
|
||||
if (el->prev) el->prev->next = el->next;
|
||||
else share.buckets[hash_num] = el->next;
|
||||
share.buckets[hash_num] = evas_object_list_remove(share.buckets[hash_num], el);
|
||||
free(el);
|
||||
}
|
||||
else
|
||||
|
@ -119,6 +120,7 @@ evas_stringshare_del(const char *str)
|
|||
if (el->next) el->next->prev = el->prev;
|
||||
el->prev = NULL;
|
||||
el->next = share.buckets[hash_num];
|
||||
el->next->prev = el;
|
||||
share.buckets[hash_num] = el;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,16 +13,13 @@ static Evas_Bool font_flush_free_glyph_cb(Evas_Hash *hash, const char *key, void
|
|||
RGBA_Font_Source *
|
||||
evas_common_font_source_memory_load(const char *name, const void *data, int data_size)
|
||||
{
|
||||
int error, len;
|
||||
int error;
|
||||
RGBA_Font_Source *fs;
|
||||
|
||||
len = strlen(name);
|
||||
fs = calloc(1, sizeof(RGBA_Font_Source) + len + 1 + data_size);
|
||||
fs = calloc(1, sizeof(RGBA_Font_Source) + data_size);
|
||||
if (!fs) return NULL;
|
||||
fs->name = ((char *)fs) + sizeof(RGBA_Font_Source);
|
||||
strcpy(fs->name, name);
|
||||
fs->file = NULL;
|
||||
fs->data = fs->name + len + 1;
|
||||
fs->data = ((unsigned char *)fs) + sizeof(RGBA_Font_Source);
|
||||
fs->current_size = 0;
|
||||
memcpy(fs->data, data, data_size);
|
||||
fs->data_size = data_size;
|
||||
|
@ -32,13 +29,10 @@ evas_common_font_source_memory_load(const char *name, const void *data, int data
|
|||
free(fs);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fs->name = evas_stringshare_add(name);
|
||||
error = FT_Select_Charmap(fs->ft.face, ft_encoding_unicode);
|
||||
|
||||
fs->ft.orig_upem = fs->ft.face->units_per_EM;
|
||||
|
||||
fs->references = 1;
|
||||
|
||||
fonts_src = evas_object_list_prepend(fonts_src, fs);
|
||||
return fs;
|
||||
}
|
||||
|
@ -46,14 +40,11 @@ evas_common_font_source_memory_load(const char *name, const void *data, int data
|
|||
RGBA_Font_Source *
|
||||
evas_common_font_source_load(const char *name)
|
||||
{
|
||||
int error, len;
|
||||
int error;
|
||||
RGBA_Font_Source *fs;
|
||||
|
||||
len = strlen(name);
|
||||
fs = calloc(1, sizeof(RGBA_Font_Source) + len + 1);
|
||||
fs = calloc(1, sizeof(RGBA_Font_Source));
|
||||
if (!fs) return NULL;
|
||||
fs->name = ((char *)fs) + sizeof(RGBA_Font_Source);
|
||||
strcpy(fs->name, name);
|
||||
fs->file = fs->name;
|
||||
fs->data = NULL;
|
||||
fs->data_size = 0;
|
||||
|
@ -64,34 +55,10 @@ evas_common_font_source_load(const char *name)
|
|||
free(fs);
|
||||
return NULL;
|
||||
}
|
||||
fs->name = evas_stringshare_add(name);
|
||||
error = FT_Select_Charmap(fs->ft.face, ft_encoding_unicode);
|
||||
if (error)
|
||||
{
|
||||
printf("cant select unicode!\n");
|
||||
/* disable this for now...
|
||||
error = FT_Select_Charmap(fs->ft.face, ft_encoding_latin_2);
|
||||
if (error)
|
||||
{
|
||||
error = FT_Select_Charmap(fs->ft.face, ft_encoding_sjis);
|
||||
if (error)
|
||||
{
|
||||
error = FT_Select_Charmap(fs->ft.face, ft_encoding_gb2312);
|
||||
if (error)
|
||||
{
|
||||
error = FT_Select_Charmap(fs->ft.face, ft_encoding_big5);
|
||||
if (error)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
fs->ft.orig_upem = fs->ft.face->units_per_EM;
|
||||
|
||||
fs->references = 1;
|
||||
|
||||
fonts_src = evas_object_list_prepend(fonts_src, fs);
|
||||
return fs;
|
||||
}
|
||||
|
@ -126,6 +93,7 @@ evas_common_font_source_free(RGBA_Font_Source *fs)
|
|||
|
||||
fonts_src = evas_object_list_remove(fonts_src, fs);
|
||||
FT_Done_Face(fs->ft.face);
|
||||
if (fs->name) evas_stringshare_del(fs->name);
|
||||
free(fs);
|
||||
}
|
||||
|
||||
|
|
|
@ -200,15 +200,8 @@ load_image_file_data_png(RGBA_Image *im, const char *file, const char *key)
|
|||
fclose(f);
|
||||
return -1;
|
||||
}
|
||||
lines = (unsigned char **) malloc(h * sizeof(unsigned char *));
|
||||
lines = (unsigned char **) alloca(h * sizeof(unsigned char *));
|
||||
|
||||
if (!lines)
|
||||
{
|
||||
evas_common_image_surface_free(im->image);
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL);
|
||||
fclose(f);
|
||||
return -1;
|
||||
}
|
||||
if (hasg)
|
||||
{
|
||||
png_set_gray_to_rgb(png_ptr);
|
||||
|
@ -218,7 +211,6 @@ load_image_file_data_png(RGBA_Image *im, const char *file, const char *key)
|
|||
for (i = 0; i < h; i++)
|
||||
lines[i] = ((unsigned char *)(im->image->data)) + (i * w * sizeof(DATA32));
|
||||
png_read_image(png_ptr, lines);
|
||||
free(lines);
|
||||
png_read_end(png_ptr, info_ptr);
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL);
|
||||
fclose(f);
|
||||
|
@ -351,16 +343,10 @@ load_image_file_data_jpeg_internal(RGBA_Image *im, FILE *f)
|
|||
jpeg_destroy_decompress(&cinfo);
|
||||
return -1;
|
||||
}
|
||||
data = malloc(w * 16 * 3);
|
||||
if (!data)
|
||||
{
|
||||
jpeg_destroy_decompress(&cinfo);
|
||||
return -1;
|
||||
}
|
||||
data = alloca(w * 16 * 3);
|
||||
evas_common_image_surface_alloc(im->image);
|
||||
if (!im->image->data)
|
||||
{
|
||||
free(data);
|
||||
jpeg_destroy_decompress(&cinfo);
|
||||
return -1;
|
||||
}
|
||||
|
@ -411,7 +397,6 @@ load_image_file_data_jpeg_internal(RGBA_Image *im, FILE *f)
|
|||
}
|
||||
}
|
||||
}
|
||||
free(data);
|
||||
/* end data decoding */
|
||||
jpeg_finish_decompress(&cinfo);
|
||||
jpeg_destroy_decompress(&cinfo);
|
||||
|
@ -457,15 +442,9 @@ load_image_file_data_jpeg_alpha_internal(RGBA_Image *im, FILE *f)
|
|||
jpeg_destroy_decompress(&cinfo);
|
||||
return -1;
|
||||
}
|
||||
data = malloc(w * 16 * 3);
|
||||
if (!data)
|
||||
{
|
||||
jpeg_destroy_decompress(&cinfo);
|
||||
return -1;
|
||||
}
|
||||
data = alloca(w * 16 * 3);
|
||||
if (!im->image->data)
|
||||
{
|
||||
free(data);
|
||||
jpeg_destroy_decompress(&cinfo);
|
||||
return -1;
|
||||
}
|
||||
|
@ -518,7 +497,6 @@ load_image_file_data_jpeg_alpha_internal(RGBA_Image *im, FILE *f)
|
|||
}
|
||||
}
|
||||
}
|
||||
free(data);
|
||||
/* end data decoding */
|
||||
jpeg_finish_decompress(&cinfo);
|
||||
jpeg_destroy_decompress(&cinfo);
|
||||
|
@ -958,15 +936,14 @@ evas_common_load_image_from_file(const char *file, const char *key)
|
|||
// im->timestamp = mod_time;
|
||||
if (file)
|
||||
{
|
||||
im->info.file = strdup(file);
|
||||
im->info.file = evas_stringshare_add(file);
|
||||
// im->info.real_file = real_file;
|
||||
}
|
||||
else
|
||||
{
|
||||
// if (real_file) free(real_file);
|
||||
}
|
||||
if (key)
|
||||
im->info.key = strdup(key);
|
||||
if (key) im->info.key = evas_stringshare_add(key);
|
||||
evas_common_image_ref(im);
|
||||
return im;
|
||||
}
|
||||
|
|
|
@ -227,10 +227,10 @@ void
|
|||
evas_common_image_free(RGBA_Image *im)
|
||||
{
|
||||
if (im->image) evas_common_image_surface_free(im->image);
|
||||
if (im->info.file) free(im->info.file);
|
||||
if (im->info.real_file) free(im->info.real_file);
|
||||
if (im->info.key) free(im->info.key);
|
||||
if (im->info.comment) free(im->info.comment);
|
||||
if (im->info.file) evas_stringshare_del(im->info.file);
|
||||
// if (im->info.real_file) evas_stringshare_del(im->info.real_file);
|
||||
if (im->info.key) evas_stringshare_del(im->info.key);
|
||||
if (im->info.comment) evas_stringshare_del(im->info.comment);
|
||||
free(im);
|
||||
}
|
||||
|
||||
|
@ -311,18 +311,6 @@ evas_common_image_flush_cache(void)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
evas_common_image_free_cache(void)
|
||||
{
|
||||
while (cache)
|
||||
{
|
||||
RGBA_Image *im = (RGBA_Image *) cache;
|
||||
|
||||
evas_common_image_uncache(im);
|
||||
evas_common_image_free(im);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
evas_common_image_set_cache(int size)
|
||||
{
|
||||
|
@ -347,23 +335,23 @@ evas_common_image_store(RGBA_Image *im)
|
|||
if (im->flags & RGBA_IMAGE_INDEXED) return;
|
||||
if ((!im->info.file) && (!im->info.key)) return;
|
||||
l1 = 0;
|
||||
if (im->info.real_file) l1 = strlen(im->info.real_file);
|
||||
else if (im->info.file) l1 = strlen(im->info.file);
|
||||
// if (im->info.real_file) l1 = strlen(im->info.real_file);
|
||||
// else
|
||||
if (im->info.file) l1 = strlen(im->info.file);
|
||||
l2 = 0;
|
||||
if (im->info.key) l2 = strlen(im->info.key);
|
||||
snprintf(buf, sizeof(buf), "%llx", im->timestamp);
|
||||
l3 = strlen(buf);
|
||||
key = malloc(l1 + 5 + l2 + 5 + l3 +1);
|
||||
if (!key) return;
|
||||
key = alloca(l1 + 5 + l2 + 5 + l3 +1);
|
||||
key[0] = 0;
|
||||
if (im->info.real_file) strcpy(key, im->info.real_file);
|
||||
else if (im->info.file) strcpy(key, im->info.file);
|
||||
// if (im->info.real_file) strcpy(key, im->info.real_file);
|
||||
// else
|
||||
if (im->info.file) strcpy(key, im->info.file);
|
||||
strcat(key, "//://");
|
||||
if (im->info.key) strcat(key, im->info.key);
|
||||
strcat(key, "//://");
|
||||
strcat(key, buf);
|
||||
images = evas_hash_add(images, key, im);
|
||||
free(key);
|
||||
im->flags |= RGBA_IMAGE_INDEXED;
|
||||
}
|
||||
|
||||
|
@ -377,23 +365,23 @@ evas_common_image_unstore(RGBA_Image *im)
|
|||
if (!(im->flags & RGBA_IMAGE_INDEXED)) return;
|
||||
if ((!im->info.file) && (!im->info.key)) return;
|
||||
l1 = 0;
|
||||
if (im->info.real_file) l1 = strlen(im->info.real_file);
|
||||
else if (im->info.file) l1 = strlen(im->info.file);
|
||||
// if (im->info.real_file) l1 = strlen(im->info.real_file);
|
||||
// else
|
||||
if (im->info.file) l1 = strlen(im->info.file);
|
||||
l2 = 0;
|
||||
if (im->info.key) l2 = strlen(im->info.key);
|
||||
snprintf(buf, sizeof(buf), "%llx", im->timestamp);
|
||||
l3 = strlen(buf);
|
||||
key = malloc(l1 + 5 + l2 + 5 + l3 +1);
|
||||
if (!key) return;
|
||||
key = alloca(l1 + 5 + l2 + 5 + l3 +1);
|
||||
key[0] = 0;
|
||||
if (im->info.real_file) strcpy(key, im->info.real_file);
|
||||
else if (im->info.file) strcpy(key, im->info.file);
|
||||
// if (im->info.real_file) strcpy(key, im->info.real_file);
|
||||
// else
|
||||
if (im->info.file) strcpy(key, im->info.file);
|
||||
strcat(key, "//://");
|
||||
if (im->info.key) strcat(key, im->info.key);
|
||||
strcat(key, "//://");
|
||||
strcat(key, buf);
|
||||
images = evas_hash_del(images, key, im);
|
||||
free(key);
|
||||
im->flags &= ~RGBA_IMAGE_INDEXED;
|
||||
}
|
||||
|
||||
|
@ -418,12 +406,7 @@ evas_common_image_find(const char *filename, const char *key, DATA64 timestamp)
|
|||
if (key) l2 = strlen(key);
|
||||
snprintf(buf, sizeof(buf), "%llx", timestamp);
|
||||
l3 = strlen(buf);
|
||||
str = malloc(l1 + 5 + l2 + 5 + l3 +1);
|
||||
if (!str)
|
||||
{
|
||||
if (real_filename) free(real_filename);
|
||||
return NULL;
|
||||
}
|
||||
str = alloca(l1 + 5 + l2 + 5 + l3 +1);
|
||||
str[0] = 0;
|
||||
if (real_filename) strcpy(str, real_filename);
|
||||
else if (filename) strcpy(str, filename);
|
||||
|
@ -432,10 +415,9 @@ evas_common_image_find(const char *filename, const char *key, DATA64 timestamp)
|
|||
strcat(str, "//://");
|
||||
strcat(str, buf);
|
||||
im = evas_hash_find(images, str);
|
||||
free(str);
|
||||
if (im)
|
||||
{
|
||||
if (real_filename) free(real_filename);
|
||||
// if (real_filename) free(real_filename);
|
||||
return im;
|
||||
}
|
||||
|
||||
|
@ -445,6 +427,7 @@ evas_common_image_find(const char *filename, const char *key, DATA64 timestamp)
|
|||
|
||||
im = (RGBA_Image *)l;
|
||||
ok = 0;
|
||||
/*
|
||||
if ((real_filename) && (im->info.real_file))
|
||||
{
|
||||
if ((im->info.real_file) &&
|
||||
|
@ -453,6 +436,7 @@ evas_common_image_find(const char *filename, const char *key, DATA64 timestamp)
|
|||
ok++;
|
||||
}
|
||||
else
|
||||
*/
|
||||
{
|
||||
if ((filename) && (im->info.file) &&
|
||||
(!strcmp(filename, im->info.file)))
|
||||
|
@ -469,11 +453,11 @@ evas_common_image_find(const char *filename, const char *key, DATA64 timestamp)
|
|||
ok++;
|
||||
if (ok >= 3)
|
||||
{
|
||||
if (real_filename) free(real_filename);
|
||||
// if (real_filename) free(real_filename);
|
||||
return im;
|
||||
}
|
||||
}
|
||||
if (real_filename) free(real_filename);
|
||||
// if (real_filename) free(real_filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -484,7 +468,7 @@ evas_common_image_ram_usage(RGBA_Image *im)
|
|||
|
||||
ram += sizeof(struct _RGBA_Image);
|
||||
if (im->info.file) ram += strlen(im->info.file);
|
||||
if (im->info.real_file) ram += strlen(im->info.real_file);
|
||||
// if (im->info.real_file) ram += strlen(im->info.real_file);
|
||||
if (im->info.key) ram += strlen(im->info.key);
|
||||
if (im->info.comment) ram += strlen(im->info.comment);
|
||||
if ((im->image) && (im->image->data) && (!im->image->no_free))
|
||||
|
@ -499,3 +483,15 @@ evas_common_image_dirty(RGBA_Image *im)
|
|||
im->flags |= RGBA_IMAGE_IS_DIRTY;
|
||||
}
|
||||
|
||||
void
|
||||
evas_common_image_free_cache(void)
|
||||
{
|
||||
while (cache)
|
||||
{
|
||||
RGBA_Image *im = (RGBA_Image *) cache;
|
||||
|
||||
evas_common_image_uncache(im);
|
||||
evas_common_image_free(im);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue