Enlightenment CVS committal Author : raster Project : e17 Module : libs/evas
Dir : e17/libs/evas/src/lib/engines/common Modified Files: evas_font_load.c Log Message: reduce a few more alloc counts by merging =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/evas/src/lib/engines/common/evas_font_load.c,v retrieving revision 1.23 retrieving revision 1.24 diff -u -3 -r1.23 -r1.24 --- evas_font_load.c 7 Sep 2005 02:31:30 -0000 1.23 +++ evas_font_load.c 26 Nov 2005 05:24:25 -0000 1.24 @@ -13,28 +13,22 @@ RGBA_Font_Source * evas_common_font_source_memory_load(const char *name, const void *data, int data_size) { - int error; + int error, len; RGBA_Font_Source *fs; - fs = calloc(1, sizeof(RGBA_Font_Source)); + len = strlen(name); + fs = calloc(1, sizeof(RGBA_Font_Source) + len + 1 + data_size); if (!fs) return NULL; - fs->name = strdup(name); + fs->name = ((char *)fs) + sizeof(RGBA_Font_Source); + strcpy(fs->name, name); fs->file = NULL; - fs->data = malloc(data_size); + fs->data = fs->name + len + 1; fs->current_size = 0; - if (!fs->data) - { - if (fs->name) free(fs->name); - free(fs); - return NULL; - } memcpy(fs->data, data, data_size); fs->data_size = data_size; error = FT_New_Memory_Face(evas_ft_lib, fs->data, fs->data_size, 0, &(fs->ft.face)); if (error) { - if (fs->name) free(fs->name); - if (fs->data) free(fs->data); free(fs); return NULL; } @@ -52,51 +46,24 @@ RGBA_Font_Source * evas_common_font_source_load(const char *name) { - int error; + int error, len; RGBA_Font_Source *fs; - fs = calloc(1, sizeof(RGBA_Font_Source)); + len = strlen(name); + fs = calloc(1, sizeof(RGBA_Font_Source) + len + 1); if (!fs) return NULL; - fs->name = strdup(name); - fs->file = strdup(name); + fs->name = ((char *)fs) + sizeof(RGBA_Font_Source); + strcpy(fs->name, name); + fs->file = fs->name; fs->data = NULL; fs->data_size = 0; fs->current_size = 0; error = FT_New_Face(evas_ft_lib, fs->file, 0, &(fs->ft.face)); if (error) { - if (fs->name) free(fs->name); - if (fs->file) free(fs->file); free(fs); return NULL; } -#if 0 /* debugging to look at charmaps in a ttf */ - printf("charmaps [%s]: %i\n", name, fs->ft.face->num_charmaps); - { - int i; - - for (i = 0; i < fs->ft.face->num_charmaps; i++) - { - printf(" %i: %x, ", - i, fs->ft.face->charmaps[i]->encoding); - if (fs->ft.face->charmaps[i]->encoding == FT_ENCODING_NONE) printf("none\n"); - else if (fs->ft.face->charmaps[i]->encoding == FT_ENCODING_UNICODE) printf("unicode\n"); - else if (fs->ft.face->charmaps[i]->encoding == FT_ENCODING_MS_SYMBOL) printf("ms_symbol\n"); - else if (fs->ft.face->charmaps[i]->encoding == FT_ENCODING_SJIS) printf("sjis\n"); - else if (fs->ft.face->charmaps[i]->encoding == FT_ENCODING_GB2312) printf("gb3212\n"); - else if (fs->ft.face->charmaps[i]->encoding == FT_ENCODING_BIG5) printf("big5\n"); - else if (fs->ft.face->charmaps[i]->encoding == FT_ENCODING_WANSUNG) printf("wansung\n"); - else if (fs->ft.face->charmaps[i]->encoding == FT_ENCODING_JOHAB) printf("johab\n"); - else if (fs->ft.face->charmaps[i]->encoding == FT_ENCODING_ADOBE_LATIN_1) printf("adobe_latin_1\n"); - else if (fs->ft.face->charmaps[i]->encoding == FT_ENCODING_ADOBE_STANDARD) printf("adobe_standard\n"); - else if (fs->ft.face->charmaps[i]->encoding == FT_ENCODING_ADOBE_EXPERT) printf("adobe_expert\n"); - else if (fs->ft.face->charmaps[i]->encoding == FT_ENCODING_ADOBE_CUSTOM) printf("adobe_custom\n"); - else if (fs->ft.face->charmaps[i]->encoding == FT_ENCODING_APPLE_ROMAN) printf("apple_roman\n"); - else printf("UNKNOWN"); - printf("\n"); - } - } -#endif error = FT_Select_Charmap(fs->ft.face, ft_encoding_unicode); if (error) { @@ -158,9 +125,6 @@ if (fs->references > 0) return; fonts_src = evas_object_list_remove(fonts_src, fs); - if (fs->name) free(fs->name); - if (fs->file) free(fs->file); - if (fs->data) free(fs->data); FT_Done_Face(fs->ft.face); free(fs); } @@ -221,12 +185,7 @@ fi->src = evas_common_font_source_find(name); if (!fi->src) - { -/* printf("REAL LOAD FILE %s %i\n", name, size);*/ - fi->src = evas_common_font_source_load(name); - } -/* else*/ -/* printf("REAL LOAD SIZE %s %i\n", name, size);*/ + fi->src = evas_common_font_source_load(name); if (!fi->src) { @@ -303,7 +262,6 @@ fi = evas_common_font_int_memory_load(name, size, data, data_size); if (!fi) return NULL; -// printf("LOAD FONT MEM %s %i\n", name, size); fn = calloc(1, sizeof(RGBA_Font)); if (!fn) { @@ -322,7 +280,6 @@ fi = evas_common_font_int_load(name, size); if (!fi) return NULL; -// printf("LOAD FONT FILE %s %i\n", name, size); fn = calloc(1, sizeof(RGBA_Font)); if (!fn) { @@ -484,13 +441,11 @@ { Evas_Object_List *l; -// printf("SEARCH!\n"); for (l = fonts; l; l = l->next) { RGBA_Font_Int *fi; fi = (RGBA_Font_Int *)l; -// printf("%s == %s, %i == %i\n", name, fi->src->name, size, fi->size); if ((fi->size == size) && (!strcmp(name, fi->src->name))) { if (fi->references == 0) evas_common_font_int_modify_cache_by(fi, -1); ------------------------------------------------------- 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