diff options
| author | MenTaLguY <mental@rydia.net> | 2006-05-28 19:51:13 +0000 |
|---|---|---|
| committer | mental <mental@users.sourceforge.net> | 2006-05-28 19:51:13 +0000 |
| commit | 2d08a9d98d19a0581eeae687bb0322dc98806d40 (patch) | |
| tree | 3adec19e80f170b623e41454aae370cb7c75dade /src/libnrtype | |
| parent | okay, that looked better in the icon preview than it did in practice; putting... (diff) | |
| download | inkscape-2d08a9d98d19a0581eeae687bb0322dc98806d40.tar.gz inkscape-2d08a9d98d19a0581eeae687bb0322dc98806d40.zip | |
replace nr_new() with g_new(), and try to converge on using the glib allocator a little more instead of the others (aside from libgc)
(bzr r1044)
Diffstat (limited to 'src/libnrtype')
| -rw-r--r-- | src/libnrtype/FontFactory.cpp | 23 | ||||
| -rwxr-xr-x | src/libnrtype/Layout-TNG-Output.cpp | 3 | ||||
| -rw-r--r-- | src/libnrtype/nr-type-primitives.cpp | 7 |
3 files changed, 18 insertions, 15 deletions
diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp index 5fc7e0b3b..b55dc50c2 100644 --- a/src/libnrtype/FontFactory.cpp +++ b/src/libnrtype/FontFactory.cpp @@ -16,6 +16,7 @@ # include "config.h" #endif +#include <glib/gmem.h> #include <glibmm/i18n.h> // _() /* Freetype2 */ @@ -237,17 +238,17 @@ style_record_compare(void const *aa, void const *bb) static void font_factory_name_list_destructor(NRNameList *list) { for (unsigned int i = 0; i < list->length; i++) - free(list->names[i]); - if ( list->names ) nr_free(list->names); + g_free(list->names[i]); + if ( list->names ) g_free(list->names); } static void font_factory_style_list_destructor(NRStyleList *list) { for (unsigned int i = 0; i < list->length; i++) { - free((void *) (list->records)[i].name); - free((void *) (list->records)[i].descr); + g_free((void *) (list->records)[i].name); + g_free((void *) (list->records)[i].descr); } - if ( list->records ) nr_free(list->records); + if ( list->records ) g_free(list->records); } /** @@ -295,7 +296,7 @@ font_factory::font_factory(void) fontSize = 512; nbEnt = 0; maxEnt = 32; - ents = (font_entry*)malloc(maxEnt*sizeof(font_entry)); + ents = (font_entry*)g_malloc(maxEnt*sizeof(font_entry)); #ifdef USE_PANGO_WIN32 hScreenDC = pango_win32_get_dc(); @@ -313,7 +314,7 @@ font_factory::font_factory(void) font_factory::~font_factory(void) { for (int i = 0;i < nbEnt;i++) ents[i].f->Unref(); - if ( ents ) free(ents); + if ( ents ) g_free(ents); g_object_unref(fontServer); #ifdef USE_PANGO_WIN32 @@ -375,7 +376,7 @@ font_instance *font_factory::Face(PangoFontDescription *descr, bool canFail) if ( canFail ) { char *tc = pango_font_description_to_string(descr); PANGO_DEBUG("falling back from %s to Sans because InstallFace failed\n",tc); - free(tc); + g_free(tc); pango_font_description_set_family(descr,"Sans"); res = Face(descr,false); } @@ -477,7 +478,7 @@ void font_factory::UnrefFace(font_instance *who) // not found char *tc = pango_font_description_to_string(who->descr); g_warning("unrefFace %p=%s: failed\n",who,tc); - free(tc); + g_free(tc); } else { loadedFaces.erase(loadedFaces.find(who->descr)); // printf("unrefFace %p: success\n",who); @@ -493,7 +494,7 @@ NRNameList *font_factory::Families(NRNameList *flist) PANGO_DEBUG("got %d families\n", nbFam); flist->length = nbFam; - flist->names = (guchar **)malloc(nbFam*sizeof(guchar*)); + flist->names = (guchar **)g_malloc(nbFam*sizeof(guchar*)); flist->destructor = font_factory_name_list_destructor; for (int i = 0;i < nbFam;i++) { @@ -545,7 +546,7 @@ NRStyleList *font_factory::Styles(gchar const *family, NRStyleList *slist) int nFaces = 0; pango_font_family_list_faces(theFam, &faces, &nFaces); - slist->records = (NRStyleRecord *) malloc(nFaces * sizeof(NRStyleRecord)); + slist->records = (NRStyleRecord *) g_malloc(nFaces * sizeof(NRStyleRecord)); slist->destructor = font_factory_style_list_destructor; int nr = 0; diff --git a/src/libnrtype/Layout-TNG-Output.cpp b/src/libnrtype/Layout-TNG-Output.cpp index bdcc6cf3f..40bd71027 100755 --- a/src/libnrtype/Layout-TNG-Output.cpp +++ b/src/libnrtype/Layout-TNG-Output.cpp @@ -8,6 +8,7 @@ * * Released under GNU GPL, read the file 'COPYING' for more information */ +#include <glib/gmem.h> #include "Layout-TNG.h" #include "display/nr-arena-glyphs.h" #include "style.h" @@ -145,7 +146,7 @@ void Layout::print(SPPrintContext *ctx, sp_print_fill(ctx, &abp, &ctm, text_source->style, pbox, dbox, bbox); if (text_source->style->stroke.type != SP_PAINT_TYPE_NONE) sp_print_stroke(ctx, &abp, &ctm, text_source->style, pbox, dbox, bbox); - nr_free(abp.path); + g_free(abp.path); } glyph_index++; } else { diff --git a/src/libnrtype/nr-type-primitives.cpp b/src/libnrtype/nr-type-primitives.cpp index 616134383..34b1e43b8 100644 --- a/src/libnrtype/nr-type-primitives.cpp +++ b/src/libnrtype/nr-type-primitives.cpp @@ -14,6 +14,7 @@ #include <stdlib.h> #include <string.h> +#include <glib/gmem.h> #include <libnr/nr-macros.h> #include "nr-type-primitives.h" @@ -65,10 +66,10 @@ nr_type_dict_new (void) NRTypeDict *td; int i; - td = nr_new (NRTypeDict, 1); + td = g_new (NRTypeDict, 1); td->size = NR_DICTSIZE; - td->entries = nr_new (NRTDEntry *, td->size); + td->entries = g_new (NRTDEntry *, td->size); for (i = 0; i < NR_DICTSIZE; i++) { td->entries[i] = NULL; } @@ -152,7 +153,7 @@ nr_td_entry_new (void) if (!nr_tde_free_list) { int i; - nr_tde_free_list = nr_new (NRTDEntry, NR_TDE_BLOCK_SIZE); + nr_tde_free_list = g_new (NRTDEntry, NR_TDE_BLOCK_SIZE); for (i = 0; i < (NR_TDE_BLOCK_SIZE - 1); i++) { nr_tde_free_list[i].next = nr_tde_free_list + i + 1; } |
