diff options
40 files changed, 216 insertions, 168 deletions
@@ -1,5 +1,32 @@ 2006-01-29 Behdad Esfahbod <behdad@gnome.org> + * modules/arabic/arabic-fc.c, modules/basic/basic-fc.c + modules/hebrew/hebrew-fc.c, modules/indic/indic-fc.c + modules/khmer/khmer-fc.c, modules/syriac/syriac-fc.c + modules/thai/thai-ot.c, modules/thai/thai-shaper.c + modules/tibetan/tibetan-fc.c: If locking font face failed, + do not assert, just return zero glyphs with an implicit + warning. + + * pango/fonts.c, pango/glyphstring.c pango/modules.c + pango/pango-color.c, pango/pango-context.c + pango/pango-coverage.c, pango/pango-fontmap.c + pango/pango-glyph-item.c, pango/pango-item.c + pango/pango-layout.c, pango/pango-markup.c + pango/pango-ot-buffer.c, pango/pango-script.c + pango/pango-tabs.c, pango/pango-utils.c + pango/pangoatsui-fontmap.c, pango/pangocairo-fcfont.c + pango/pangocairo-fcfontmap.c, pango/pangocairo-fontmap.c + pango/pangocairo-win32font.c, pango/pangofc-font.c + pango/pangofc-fontmap.c, pango/pangoft2-fontmap.c + pango/pangoft2-render.c, pango/pangoft2.c + pango/pangowin32-fontcache.c, pango/pangoxft-font.c + pango/pangoxft-render.c, pango/break.c pango/ellipsize.c: + Use g_slice for allocating all types. Also, change some + g_error's to g_critical's... + +2006-01-29 Behdad Esfahbod <behdad@gnome.org> + Do not crash if the (win32 typically) shaper fails. Bug #304702: * pango/pango-engine.c (_pango_engine_shape_shape): Set num_glyphs to diff --git a/modules/arabic/arabic-fc.c b/modules/arabic/arabic-fc.c index e03e9ba6..d72aebc1 100644 --- a/modules/arabic/arabic-fc.c +++ b/modules/arabic/arabic-fc.c @@ -256,16 +256,16 @@ arabic_engine_shape (PangoEngineShape *engine, PangoAnalysis *analysis, PangoGlyphString *glyphs) { - glong n_chars; - gunichar *wcs; - int i; - const char *p; - gulong *properties = NULL; + PangoFcFont *fc_font; FT_Face face; PangoOTRuleset *ruleset; PangoOTBuffer *buffer; - PangoFcFont *fc_font; + gulong *properties = NULL; + glong n_chars; + gunichar *wcs; + const char *p; int cluster = 0; + int i; g_return_if_fail (font != NULL); g_return_if_fail (text != NULL); @@ -273,9 +273,8 @@ arabic_engine_shape (PangoEngineShape *engine, g_return_if_fail (analysis != NULL); fc_font = PANGO_FC_FONT (font); - face = pango_fc_font_lock_face (fc_font); - g_assert (face); + g_return_if_fail (face != NULL); ruleset = get_ruleset (face); if (!ruleset) diff --git a/modules/basic/basic-fc.c b/modules/basic/basic-fc.c index caa46cf4..c260f42b 100644 --- a/modules/basic/basic-fc.c +++ b/modules/basic/basic-fc.c @@ -327,27 +327,24 @@ basic_engine_shape (PangoEngineShape *engine, PangoAnalysis *analysis, PangoGlyphString *glyphs) { - PangoFcFont *fc_font = PANGO_FC_FONT (font); + PangoFcFont *fc_font; FT_Face face; PangoOTRuleset *ruleset; PangoOTBuffer *buffer; gint unknown_property = 0; - int n_chars; - int i; + glong n_chars; const char *p; int cluster = 0; + int i; g_return_if_fail (font != NULL); g_return_if_fail (text != NULL); g_return_if_fail (length >= 0); g_return_if_fail (analysis != NULL); - n_chars = g_utf8_strlen (text, length); - pango_glyph_string_set_size (glyphs, n_chars); - + fc_font = PANGO_FC_FONT (font); face = pango_fc_font_lock_face (fc_font); - g_assert (face != NULL); - + g_return_if_fail (face != NULL); ruleset = get_ruleset (face); if (!ruleset) @@ -360,6 +357,9 @@ basic_engine_shape (PangoEngineShape *engine, buffer = pango_ot_buffer_new (fc_font); pango_ot_buffer_set_rtl (buffer, analysis->level % 2 != 0); + n_chars = g_utf8_strlen (text, length); + pango_glyph_string_set_size (glyphs, n_chars); + p = text; for (i=0; i < n_chars; i++) { diff --git a/modules/hebrew/hebrew-fc.c b/modules/hebrew/hebrew-fc.c index c22f118f..9ffe289c 100644 --- a/modules/hebrew/hebrew-fc.c +++ b/modules/hebrew/hebrew-fc.c @@ -295,14 +295,15 @@ hebrew_engine_shape (PangoEngineShape *engine, PangoAnalysis *analysis, PangoGlyphString *glyphs) { - const gchar *p; - gint i; - glong n_chars; - gint unknown_property = 0; + PangoFcFont *fc_font; FT_Face face; PangoOTRuleset *ruleset; PangoOTBuffer *buffer; - PangoFcFont *fc_font; + gint unknown_property = 0; + glong n_chars; + const char *p; + int cluster = 0; + int i; g_return_if_fail (font != NULL); g_return_if_fail (text != NULL); @@ -310,9 +311,8 @@ hebrew_engine_shape (PangoEngineShape *engine, g_return_if_fail (analysis != NULL); fc_font = PANGO_FC_FONT (font); - face = pango_fc_font_lock_face (fc_font); - g_assert (face); + g_return_if_fail (face != NULL); ruleset = get_ruleset (face); if (!ruleset) @@ -327,7 +327,6 @@ hebrew_engine_shape (PangoEngineShape *engine, n_chars = g_utf8_strlen (text, length); p = text; - for (i=0; i < n_chars; i++) { gunichar wc; @@ -335,7 +334,6 @@ hebrew_engine_shape (PangoEngineShape *engine, PangoGlyph index; char buf[6]; const char *input; - int cluster = 0; wc = g_utf8_get_char (p); input = p; diff --git a/modules/indic/indic-fc.c b/modules/indic/indic-fc.c index 4e6fdfcc..3e3ec23e 100644 --- a/modules/indic/indic-fc.c +++ b/modules/indic/indic-fc.c @@ -325,17 +325,17 @@ indic_engine_shape (PangoEngineShape *engine, PangoAnalysis *analysis, PangoGlyphString *glyphs) { + PangoFcFont *fc_font; + FT_Face face; + PangoOTRuleset *gsub_ruleset, *gpos_ruleset; + PangoOTBuffer *buffer; glong i, n_chars, n_glyphs; gulong *tags = NULL; gunichar *wc_in = NULL, *wc_out = NULL; glong *utf8_offsets = NULL; glong *indices = NULL; - FT_Face face; - PangoOTRuleset *gsub_ruleset = NULL, *gpos_ruleset = NULL; - PangoOTBuffer *buffer; IndicEngineFc *indic_shape_engine = NULL; const PangoIndicInfo *indic_info = NULL; - PangoFcFont *fc_font; MPreFixups *mprefixups; g_return_if_fail (font != NULL); @@ -345,7 +345,7 @@ indic_engine_shape (PangoEngineShape *engine, fc_font = PANGO_FC_FONT (font); face = pango_fc_font_lock_face (fc_font); - g_assert (face != NULL); + g_return_if_fail (face != NULL); indic_shape_engine = (IndicEngineFc *) engine; diff --git a/modules/khmer/khmer-fc.c b/modules/khmer/khmer-fc.c index 7d768c5e..75cebf87 100644 --- a/modules/khmer/khmer-fc.c +++ b/modules/khmer/khmer-fc.c @@ -522,25 +522,32 @@ khmer_engine_shape (PangoEngineShape *engine, PangoAnalysis *analysis, PangoGlyphString *glyphs) { - PangoFcFont *fc_font = PANGO_FC_FONT (font); + PangoFcFont *fc_font; FT_Face face; - PangoOTBuffer *buffer; PangoOTRuleset *ruleset; - glong n_chars, i; + PangoOTBuffer *buffer; + glong n_chars; gunichar *wcs; const char *p; + int i; glong syllable; KhmerCharClass charClass; glong cursor = 0; - buffer = pango_ot_buffer_new (fc_font); + g_return_if_fail (font != NULL); + g_return_if_fail (text != NULL); + g_return_if_fail (length >= 0); + g_return_if_fail (analysis != NULL); + fc_font = PANGO_FC_FONT (font); face = pango_fc_font_lock_face (fc_font); - g_assert (face); + g_return_if_fail (face != NULL); + + buffer = pango_ot_buffer_new (fc_font); wcs = g_utf8_to_ucs4_fast (text, length, &n_chars); - p = text; + p = text; /* This loop only exits when we reach the end of a run, which may contain * several syllables. */ diff --git a/modules/syriac/syriac-fc.c b/modules/syriac/syriac-fc.c index ed689d59..300ce5d3 100644 --- a/modules/syriac/syriac-fc.c +++ b/modules/syriac/syriac-fc.c @@ -248,16 +248,16 @@ syriac_engine_shape (PangoEngineShape *engine, PangoAnalysis *analysis, PangoGlyphString *glyphs) { - glong n_chars; - gunichar *wcs; - int i; - const char *p; - gulong *properties = NULL; + PangoFcFont *fc_font; FT_Face face; PangoOTRuleset *ruleset; PangoOTBuffer *buffer; - PangoFcFont *fc_font; + gulong *properties = NULL; + glong n_chars; + gunichar *wcs; + const char *p; int cluster = 0; + int i; g_return_if_fail (font != NULL); g_return_if_fail (text != NULL); @@ -265,9 +265,8 @@ syriac_engine_shape (PangoEngineShape *engine, g_return_if_fail (analysis != NULL); fc_font = PANGO_FC_FONT (font); - face = pango_fc_font_lock_face (fc_font); - g_assert (face); + g_return_if_fail (face != NULL); ruleset = get_ruleset (face); if (!ruleset) diff --git a/modules/thai/thai-ot.c b/modules/thai/thai-ot.c index b82033bb..23c20190 100644 --- a/modules/thai/thai-ot.c +++ b/modules/thai/thai-ot.c @@ -76,7 +76,7 @@ thai_ot_get_ruleset (PangoFont *font) fc_font = PANGO_FC_FONT (font); face = pango_fc_font_lock_face (fc_font); - g_assert (face != NULL); + g_return_val_if_fail (face != NULL, NULL); info = pango_ot_info_get (face); if (info != NULL) @@ -148,7 +148,7 @@ lao_ot_get_ruleset (PangoFont *font) fc_font = PANGO_FC_FONT (font); face = pango_fc_font_lock_face (fc_font); - g_assert (face != NULL); + g_return_val_if_fail (face != NULL, NULL); info = pango_ot_info_get (face); if (info != NULL) @@ -216,9 +216,6 @@ thai_ot_shape (PangoFont *font, PangoOTRuleset *th_ruleset; PangoOTRuleset *lo_ruleset; - g_return_if_fail (font != NULL); - g_return_if_fail (glyphs != NULL); - th_ruleset = thai_ot_get_ruleset (font); lo_ruleset = lao_ot_get_ruleset (font); diff --git a/modules/thai/thai-shaper.c b/modules/thai/thai-shaper.c index a2a5bf37..bb62a9c1 100644 --- a/modules/thai/thai-shaper.c +++ b/modules/thai/thai-shaper.c @@ -531,11 +531,16 @@ thai_engine_shape (PangoEngineShape *engine, PangoAnalysis *analysis, PangoGlyphString *glyphs) { - ThaiFontInfo *font_info; + gint n_chars; const char *p; + ThaiFontInfo *font_info; const char *log_cluster; gunichar cluster[MAX_CLUSTER_CHRS]; - gint num_chrs; + + g_return_if_fail (font != NULL); + g_return_if_fail (text != NULL); + g_return_if_fail (length >= 0); + g_return_if_fail (analysis != NULL); pango_glyph_string_set_size (glyphs, 0); @@ -545,8 +550,8 @@ thai_engine_shape (PangoEngineShape *engine, while (p < text + length) { log_cluster = p; - p = get_next_cluster (p, text + length - p, cluster, &num_chrs); - add_cluster (font_info, glyphs, log_cluster - text, cluster, num_chrs); + p = get_next_cluster (p, text + length - p, cluster, &n_chars); + add_cluster (font_info, glyphs, log_cluster - text, cluster, n_chars); } thai_ot_shape (font, glyphs); } diff --git a/modules/tibetan/tibetan-fc.c b/modules/tibetan/tibetan-fc.c index 5df9906e..77a10ca7 100644 --- a/modules/tibetan/tibetan-fc.c +++ b/modules/tibetan/tibetan-fc.c @@ -487,25 +487,32 @@ tibetan_engine_shape (PangoEngineShape *engine, PangoAnalysis *analysis, PangoGlyphString *glyphs) { - PangoFcFont *fc_font = PANGO_FC_FONT (font); + PangoFcFont *fc_font; FT_Face face; - PangoOTBuffer *buffer; PangoOTRuleset *ruleset; - glong n_chars, i; + PangoOTBuffer *buffer; + glong n_chars; gunichar *wcs; const char *p; + int i; glong syllable; TibetanCharClass charClass; glong cursor = 0; - buffer = pango_ot_buffer_new (fc_font); + g_return_if_fail (font != NULL); + g_return_if_fail (text != NULL); + g_return_if_fail (length >= 0); + g_return_if_fail (analysis != NULL); + fc_font = PANGO_FC_FONT (font); face = pango_fc_font_lock_face (fc_font); - g_assert (face); + g_return_if_fail (face != NULL); + + buffer = pango_ot_buffer_new (fc_font); wcs = g_utf8_to_ucs4_fast (text, length, &n_chars); - p = text; + p = text; /* This loop only exits when we reach the end of a run, which may contain * several syllables. */ diff --git a/pango/break.c b/pango/break.c index aafa503f..eea7efa5 100644 --- a/pango/break.c +++ b/pango/break.c @@ -561,10 +561,7 @@ pango_default_break (const gchar *text, if (length == 0 || *text == '\0') next_wc = PARAGRAPH_SEPARATOR; else - { - next_wc = g_utf8_get_char (next); - g_assert (next_wc != 0); - } + next_wc = g_utf8_get_char (next); next_break_type = g_unichar_break_type (next_wc); next_break_type = BREAK_TYPE_SAFE (next_break_type); @@ -605,10 +602,7 @@ pango_default_break (const gchar *text, almost_done = TRUE; } else - { - next_wc = g_utf8_get_char (next); - g_assert (next_wc != 0); - } + next_wc = g_utf8_get_char (next); next_break_type = g_unichar_break_type (next_wc); next_break_type = BREAK_TYPE_SAFE (next_break_type); diff --git a/pango/ellipsize.c b/pango/ellipsize.c index d7d4a900..50b019aa 100644 --- a/pango/ellipsize.c +++ b/pango/ellipsize.c @@ -307,7 +307,7 @@ shape_ellipsis (EllipsizeState *state) */ if (!state->ellipsis_run) { - state->ellipsis_run = g_new (PangoGlyphItem, 1); + state->ellipsis_run = g_slice_new (PangoGlyphItem); state->ellipsis_run->glyphs = pango_glyph_string_new (); state->ellipsis_run->item = NULL; } diff --git a/pango/fonts.c b/pango/fonts.c index 0c0b4fa5..2142d58b 100644 --- a/pango/fonts.c +++ b/pango/fonts.c @@ -85,7 +85,7 @@ static const PangoFontDescription pfd_defaults = { PangoFontDescription * pango_font_description_new (void) { - PangoFontDescription *desc = g_new (PangoFontDescription, 1); + PangoFontDescription *desc = g_slice_new (PangoFontDescription); *desc = pfd_defaults; @@ -596,7 +596,7 @@ pango_font_description_better_match (const PangoFontDescription *desc, PangoFontDescription * pango_font_description_copy (const PangoFontDescription *desc) { - PangoFontDescription *result = g_new (PangoFontDescription, 1); + PangoFontDescription *result = g_slice_new (PangoFontDescription); *result = *desc; @@ -624,7 +624,7 @@ pango_font_description_copy (const PangoFontDescription *desc) PangoFontDescription * pango_font_description_copy_static (const PangoFontDescription *desc) { - PangoFontDescription *result = g_new (PangoFontDescription, 1); + PangoFontDescription *result = g_slice_new (PangoFontDescription); *result = *desc; if (result->family_name) @@ -723,7 +723,7 @@ pango_font_description_free (PangoFontDescription *desc) if (desc->family_name && !desc->static_family) g_free (desc->family_name); - g_free (desc); + g_slice_free (PangoFontDescription, desc); } } @@ -883,7 +883,7 @@ pango_font_description_from_string (const char *str) g_return_val_if_fail (str != NULL, NULL); - desc = g_new (PangoFontDescription, 1); + desc = g_slice_new (PangoFontDescription); desc->mask = PANGO_FONT_MASK_STYLE | PANGO_FONT_MASK_WEIGHT | @@ -1236,7 +1236,7 @@ pango_font_metrics_get_type (void) PangoFontMetrics * pango_font_metrics_new (void) { - PangoFontMetrics *metrics = g_new0 (PangoFontMetrics, 1); + PangoFontMetrics *metrics = g_slice_new0 (PangoFontMetrics); metrics->ref_count = 1; return metrics; @@ -1277,7 +1277,7 @@ pango_font_metrics_unref (PangoFontMetrics *metrics) metrics->ref_count--; if (metrics->ref_count == 0) - g_free (metrics); + g_slice_free (PangoFontMetrics, metrics); } /** diff --git a/pango/glyphstring.c b/pango/glyphstring.c index 59df32da..53a529a0 100644 --- a/pango/glyphstring.c +++ b/pango/glyphstring.c @@ -35,7 +35,7 @@ PangoGlyphString * pango_glyph_string_new (void) { - PangoGlyphString *string = g_new (PangoGlyphString, 1); + PangoGlyphString *string = g_slice_new (PangoGlyphString); string->num_glyphs = 0; string->space = 0; @@ -65,7 +65,10 @@ pango_glyph_string_set_size (PangoGlyphString *string, gint new_len) string->space *= 2; if (string->space < 0) - g_error ("%s: glyph string length overflows maximum integer size", G_STRLOC); + { + g_critical ("glyph string length overflows maximum integer size, truncated"); + new_len = string->space = G_MAXINT - 8; + } } string->glyphs = g_realloc (string->glyphs, string->space * sizeof (PangoGlyphInfo)); @@ -97,7 +100,7 @@ pango_glyph_string_get_type (void) PangoGlyphString * pango_glyph_string_copy (PangoGlyphString *string) { - PangoGlyphString *new_string = g_new (PangoGlyphString, 1); + PangoGlyphString *new_string = g_slice_new (PangoGlyphString); *new_string = *string; @@ -120,7 +123,7 @@ pango_glyph_string_free (PangoGlyphString *string) { g_free (string->glyphs); g_free (string->log_clusters); - g_free (string); + g_slice_free (PangoGlyphString, string); } /** diff --git a/pango/modules.c b/pango/modules.c index 1222b770..f7d8e42b 100644 --- a/pango/modules.c +++ b/pango/modules.c @@ -138,7 +138,7 @@ pango_find_map (PangoLanguage *language, if (!tmp_list) { - map_info = g_new (PangoMapInfo, 1); + map_info = g_slice_new (PangoMapInfo); map_info->language = language; map_info->engine_type_id = engine_type_id; map_info->render_type_id = render_type_id; @@ -286,7 +286,7 @@ handle_included_module (PangoIncludedModule *included_module, for (i = 0; i < n_engines; i++) { - PangoEnginePair *pair = g_new (PangoEnginePair, 1); + PangoEnginePair *pair = g_slice_new (PangoEnginePair); pair->info = engine_info[i]; pair->module = module; @@ -354,6 +354,12 @@ script_from_string (const char *str) return value->value; } +static void +script_info_free (PangoEngineScriptInfo *script_info, gpointer data) +{ + g_slice_free (PangoEngineScriptInfo, script_info); +} + static gboolean /* Returns true if succeeded, false if failed */ process_module_file (FILE *module_file) { @@ -363,7 +369,7 @@ process_module_file (FILE *module_file) while (pango_read_line (module_file, line_buf)) { - PangoEnginePair *pair = g_new (PangoEnginePair, 1); + PangoEnginePair *pair = g_slice_new (PangoEnginePair); PangoEngineScriptInfo *script_info; PangoScript script; GList *scripts = NULL; @@ -377,7 +383,7 @@ process_module_file (FILE *module_file) if (!pango_skip_space (&p)) { - g_free (pair); + g_slice_free (PangoEnginePair, pair); continue; } @@ -419,7 +425,7 @@ process_module_file (FILE *module_file) goto error; } - script_info = g_new (PangoEngineScriptInfo, 1); + script_info = g_slice_new (PangoEngineScriptInfo); script_info->script = script; script_info->langs = g_strdup (q + 1); @@ -454,13 +460,13 @@ process_module_file (FILE *module_file) dlloaded_engines = g_slist_prepend (dlloaded_engines, pair); error: - g_list_foreach (scripts, (GFunc)g_free, NULL); + g_list_foreach (scripts, (GFunc)script_info_free, NULL); g_list_free (scripts); if (have_error) { g_printerr ("Error reading Pango modules file\n"); - g_free(pair); + g_slice_free(PangoEnginePair, pair); break; } } @@ -581,8 +587,6 @@ map_add_engine_list (PangoMapInfo *info, static void build_map (PangoMapInfo *info) { - PangoMap *map; - const char *engine_type = g_quark_to_string (info->engine_type_id); const char *render_type = g_quark_to_string (info->render_type_id); @@ -608,8 +612,8 @@ build_map (PangoMapInfo *info) } } - info->map = map = g_new (PangoMap, 1); - map->entries = g_array_new (FALSE, TRUE, sizeof (PangoMapEntry)); + info->map = g_slice_new (PangoMap); + info->map->entries = g_array_new (FALSE, TRUE, sizeof (PangoMapEntry)); map_add_engine_list (info, dlloaded_engines, engine_type, render_type); map_add_engine_list (info, registered_engines, engine_type, render_type); diff --git a/pango/pango-color.c b/pango/pango-color.c index 172a759c..0e552d28 100644 --- a/pango/pango-color.c +++ b/pango/pango-color.c @@ -58,7 +58,7 @@ pango_color_copy (const PangoColor *src) g_return_val_if_fail (src != NULL, NULL); - ret = g_new (PangoColor, 1); + ret = g_slice_new (PangoColor); *ret = *src; @@ -76,7 +76,7 @@ pango_color_free (PangoColor *color) { g_return_if_fail (color != NULL); - g_free (color); + g_slice_free (PangoColor, color); } /* Color parsing diff --git a/pango/pango-context.c b/pango/pango-context.c index 4f75df39..e3651120 100644 --- a/pango/pango-context.c +++ b/pango/pango-context.c @@ -443,7 +443,7 @@ static void shaper_font_cache_destroy (ShaperFontCache *cache) { g_hash_table_destroy (cache->hash); - g_free (cache); + g_slice_free (ShaperFontCache, cache); } static void @@ -466,7 +466,7 @@ get_shaper_font_cache (PangoFontset *fontset) cache = g_object_get_qdata (G_OBJECT (fontset), cache_quark); if (!cache) { - cache = g_new (ShaperFontCache, 1); + cache = g_slice_new (ShaperFontCache); cache->hash = g_hash_table_new_full (g_direct_hash, NULL, NULL, (GDestroyNotify)shaper_font_element_destroy); diff --git a/pango/pango-coverage.c b/pango/pango-coverage.c index 2a68ea05..6e34f802 100644 --- a/pango/pango-coverage.c +++ b/pango/pango-coverage.c @@ -58,7 +58,7 @@ struct _PangoCoverage PangoCoverage * pango_coverage_new (void) { - PangoCoverage *coverage = g_new (PangoCoverage, 1); + PangoCoverage *coverage = g_slice_new (PangoCoverage); coverage->n_blocks = N_BLOCKS_INCREMENT; coverage->blocks = g_new0 (PangoBlockInfo, coverage->n_blocks); @@ -85,7 +85,7 @@ pango_coverage_copy (PangoCoverage *coverage) g_return_val_if_fail (coverage != NULL, NULL); - result = g_new (PangoCoverage, 1); + result = g_slice_new (PangoCoverage); result->n_blocks = coverage->n_blocks; result->blocks = g_new (PangoBlockInfo, coverage->n_blocks); result->ref_count = 1; @@ -150,7 +150,7 @@ pango_coverage_unref (PangoCoverage *coverage) } g_free (coverage->blocks); - g_free (coverage); + g_slice_free (PangoCoverage, coverage); } } @@ -447,7 +447,7 @@ PangoCoverage * pango_coverage_from_bytes (guchar *bytes, int n_bytes) { - PangoCoverage *coverage = g_new0 (PangoCoverage, 1); + PangoCoverage *coverage = g_slice_new0 (PangoCoverage); guchar *ptr = bytes; int i; diff --git a/pango/pango-fontmap.c b/pango/pango-fontmap.c index 62ffab9e..4d458445 100644 --- a/pango/pango-fontmap.c +++ b/pango/pango-fontmap.c @@ -221,7 +221,7 @@ pango_font_map_real_load_fontset (PangoFontMap *fontmap, /* Everything failed, we are screwed, there is no way to continue */ if (pango_fontset_simple_size (fonts) == 0) - g_error ("All font fallbacks failed!!!!"); + g_critical ("All font fallbacks failed!!!!"); return PANGO_FONTSET (fonts); } diff --git a/pango/pango-glyph-item.c b/pango/pango-glyph-item.c index 17ffc788..89744df1 100644 --- a/pango/pango-glyph-item.c +++ b/pango/pango-glyph-item.c @@ -96,7 +96,7 @@ pango_glyph_item_split (PangoGlyphItem *orig, num_remaining = orig->glyphs->num_glyphs - num_glyphs; - new = g_new (PangoGlyphItem, 1); + new = g_slice_new (PangoGlyphItem); split_offset = g_utf8_pointer_to_offset (text + orig->item->offset, text + orig->item->offset + split_index); new->item = pango_item_split (orig->item, split_index, split_offset); @@ -144,7 +144,7 @@ pango_glyph_item_free (PangoGlyphItem *glyph_item) if (glyph_item->glyphs) pango_glyph_string_free (glyph_item->glyphs); - g_free (glyph_item); + g_slice_free (PangoGlyphItem, glyph_item); } /** diff --git a/pango/pango-item.c b/pango/pango-item.c index 6a1481dd..7cf3bebe 100644 --- a/pango/pango-item.c +++ b/pango/pango-item.c @@ -34,7 +34,7 @@ PangoItem * pango_item_new (void) { - PangoItem *result = g_new0 (PangoItem, 1); + PangoItem *result = g_slice_new0 (PangoItem); return result; } @@ -51,7 +51,7 @@ PangoItem * pango_item_copy (PangoItem *item) { GSList *extra_attrs, *tmp_list; - PangoItem *result = g_new (PangoItem, 1); + PangoItem *result = g_slice_new (PangoItem); result->offset = item->offset; result->length = item->length; @@ -92,7 +92,7 @@ pango_item_free (PangoItem *item) if (item->analysis.font) g_object_unref (item->analysis.font); - g_free (item); + g_slice_free (PangoItem, item); } GType diff --git a/pango/pango-layout.c b/pango/pango-layout.c index 50143387..77a266fd 100644 --- a/pango/pango-layout.c +++ b/pango/pango-layout.c @@ -929,7 +929,7 @@ pango_layout_set_markup_with_accel (PangoLayout *layout, accel_char, &error)) { - g_warning ("%s: %s", G_STRLOC, error->message); + g_warning ("pango_layout_set_markup_with_accel: %s", error->message); g_error_free (error); return; } @@ -2096,7 +2096,7 @@ pango_layout_get_extents_internal (PangoLayout *layout, if (line_extents) { - Extents *ext = g_new (Extents, 1); + Extents *ext = g_slice_new (Extents); ext->baseline = baseline; ext->ink_rect = line_ink_layout; ext->logical_rect = line_logical_layout; @@ -2398,13 +2398,20 @@ static void shape_tab (PangoLayoutLine *line, PangoGlyphString *glyphs); static void -free_run (PangoLayoutRun *run, gboolean free_item) +free_run (PangoLayoutRun *run, gpointer data) { + gboolean free_item = data != NULL; if (free_item) pango_item_free (run->item); pango_glyph_string_free (run->glyphs); - g_free (run); + g_slice_free (PangoLayoutRun, run); +} + +static void +extents_free (Extents *ext, gpointer data) +{ + g_slice_free (Extents, ext); } static PangoItem * @@ -2422,7 +2429,7 @@ uninsert_run (PangoLayoutLine *line) line->length -= item->length; g_slist_free_1 (tmp_node); - free_run (run, FALSE); + free_run (run, (gpointer)FALSE); return item; } @@ -2737,7 +2744,7 @@ insert_run (PangoLayoutLine *line, PangoItem *run_item, gboolean last_run) { - PangoLayoutRun *run = g_new (PangoLayoutRun, 1); + PangoLayoutRun *run = g_slice_new (PangoLayoutRun); run->item = run_item; @@ -3373,14 +3380,9 @@ pango_layout_line_unref (PangoLayoutLine *line) if (private->ref_count == 0) { GSList *tmp_list = line->runs; - while (tmp_list) - { - free_run (tmp_list->data, TRUE); - tmp_list = tmp_list->next; - } - + g_slist_foreach (line->runs, (GFunc)free_run, GINT_TO_POINTER (1)); g_slist_free (line->runs); - g_free (line); + g_slice_free (PangoLayoutLinePrivate, private); } } @@ -4028,7 +4030,7 @@ pango_layout_line_get_extents (PangoLayoutLine *line, static PangoLayoutLine * pango_layout_line_new (PangoLayout *layout) { - PangoLayoutLinePrivate *private = g_new (PangoLayoutLinePrivate, 1); + PangoLayoutLinePrivate *private = g_slice_new (PangoLayoutLinePrivate); private->ref_count = 1; private->line.layout = layout; @@ -4525,7 +4527,7 @@ pango_layout_iter_copy (PangoLayoutIter *iter) PangoLayoutIter *new; GSList *l; - new = g_new (PangoLayoutIter, 1); + new = g_slice_new (PangoLayoutIter); new->layout = g_object_ref (iter->layout); new->line_list_link = iter->line_list_link; @@ -4596,7 +4598,7 @@ pango_layout_get_iter (PangoLayout *layout) g_return_val_if_fail (PANGO_IS_LAYOUT (layout), NULL); - iter = g_new (PangoLayoutIter, 1); + iter = g_slice_new (PangoLayoutIter); iter->layout = layout; g_object_ref (iter->layout); @@ -4642,11 +4644,11 @@ pango_layout_iter_free (PangoLayoutIter *iter) { g_return_if_fail (iter != NULL); - g_slist_foreach (iter->line_extents, (GFunc) g_free, NULL); + g_slist_foreach (iter->line_extents, (GFunc)extents_free, NULL); g_slist_free (iter->line_extents); pango_layout_line_unref (iter->line); g_object_unref (iter->layout); - g_free (iter); + g_slice_free (PangoLayoutIter, iter); } /** diff --git a/pango/pango-markup.c b/pango/pango-markup.c index a5128f3e..73e980bb 100644 --- a/pango/pango-markup.c +++ b/pango/pango-markup.c @@ -191,7 +191,7 @@ open_tag_free (OpenTag *ot) { g_slist_foreach (ot->attrs, (GFunc) pango_attribute_destroy, NULL); g_slist_free (ot->attrs); - g_free (ot); + g_slice_free (OpenTag, ot); } static void @@ -226,7 +226,7 @@ markup_data_open_tag (MarkupData *md) if (md->tag_stack) parent = md->tag_stack->data; - ot = g_new (OpenTag, 1); + ot = g_slice_new (OpenTag); ot->attrs = NULL; ot->start_index = md->index; ot->scale_level_delta = 0; @@ -315,7 +315,7 @@ markup_data_close_tag (MarkupData *md) } g_slist_free (ot->attrs); - g_free (ot); + g_slice_free (OpenTag, ot); } static void @@ -591,7 +591,7 @@ pango_parse_markup (const char *markup_text, g_return_val_if_fail (markup_text != NULL, FALSE); - md = g_new (MarkupData, 1); + md = g_slice_new (MarkupData); /* Don't bother creating these if they weren't requested; * might be useful e.g. if you just want to validate @@ -686,7 +686,7 @@ pango_parse_markup (const char *markup_text, g_assert (md->tag_stack == NULL); - g_free (md); + g_slice_free (MarkupData, md); return TRUE; @@ -700,7 +700,7 @@ pango_parse_markup (const char *markup_text, if (md->attr_list) pango_attr_list_unref (md->attr_list); - g_free (md); + g_slice_free (MarkupData, md); if (context) g_markup_parse_context_free (context); diff --git a/pango/pango-ot-buffer.c b/pango/pango-ot-buffer.c index f415c6eb..c4828a55 100644 --- a/pango/pango-ot-buffer.c +++ b/pango/pango-ot-buffer.c @@ -49,7 +49,7 @@ pango_ot_buffer_new (PangoFcFont *font) FT_Face face = pango_fc_font_lock_face (font); if (otl_buffer_new (face->memory, &buffer->buffer) != FT_Err_Ok) - g_error ("Allocation of OTLBuffer failed"); + g_critical ("Allocation of OTLBuffer failed"); /* this doesn't happen */ buffer->font = g_object_ref (font); buffer->applied_gpos = FALSE; @@ -112,7 +112,6 @@ pango_ot_buffer_add_glyph (PangoOTBuffer *buffer, { otl_buffer_add_glyph (buffer->buffer, glyph, properties, cluster); - } /** diff --git a/pango/pango-script.c b/pango/pango-script.c index d276e0f2..d0a35920 100644 --- a/pango/pango-script.c +++ b/pango/pango-script.c @@ -155,7 +155,7 @@ PangoScriptIter * pango_script_iter_new (const char *text, int length) { - PangoScriptIter *iter = g_new (PangoScriptIter, 1); + PangoScriptIter *iter = g_slice_new (PangoScriptIter); iter->text_start = text; if (length >= 0) @@ -185,7 +185,7 @@ pango_script_iter_new (const char *text, void pango_script_iter_free (PangoScriptIter *iter) { - g_free (iter); + g_slice_free (PangoScriptIter, iter); } /** diff --git a/pango/pango-tabs.c b/pango/pango-tabs.c index aedd9bce..c5d727ae 100644 --- a/pango/pango-tabs.c +++ b/pango/pango-tabs.c @@ -79,7 +79,7 @@ pango_tab_array_new (gint initial_size, * If we allowed tab array resizing we'd need to drop this * optimization. */ - array = g_new (PangoTabArray, 1); + array = g_slice_new (PangoTabArray); array->size = initial_size; array->allocated = initial_size; @@ -202,7 +202,7 @@ pango_tab_array_free (PangoTabArray *tab_array) g_free (tab_array->tabs); - g_free (tab_array); + g_slice_free (PangoTabArray, tab_array); } /** diff --git a/pango/pango-utils.c b/pango/pango-utils.c index 95ea1657..fce42896 100644 --- a/pango/pango-utils.c +++ b/pango/pango-utils.c @@ -1583,7 +1583,7 @@ alias_free (struct PangoAlias *alias) g_free (alias->families); - g_free (alias); + g_slice_free (struct PangoAlias, alias); } static void @@ -1665,7 +1665,7 @@ read_alias_file (const char *filename) if (!alias) { - alias = g_new0 (struct PangoAlias, 1); + alias = g_slice_new0 (struct PangoAlias); alias->alias = alias_key.alias; g_hash_table_insert (pango_aliases_ht, diff --git a/pango/pangoatsui-fontmap.c b/pango/pangoatsui-fontmap.c index 439e9c18..e61637fc 100644 --- a/pango/pangoatsui-fontmap.c +++ b/pango/pangoatsui-fontmap.c @@ -440,13 +440,13 @@ font_hash_key_free (FontHashKey *key) PANGO_ATSUI_FONT_MAP_GET_CLASS (key->fontmap)->context_key_free (key->fontmap, key->context_key); - g_free (key); + g_slice_free (FontHashKey, key); } static FontHashKey * font_hash_key_copy (FontHashKey *old) { - FontHashKey *key = g_new (FontHashKey, 1); + FontHashKey *key = g_slice_new (FontHashKey); key->fontmap = old->fontmap; key->matrix = old->matrix; diff --git a/pango/pangocairo-fcfont.c b/pango/pangocairo-fcfont.c index fe2a635f..38145711 100644 --- a/pango/pangocairo-fcfont.c +++ b/pango/pangocairo-fcfont.c @@ -267,10 +267,9 @@ pango_cairo_fc_font_get_metrics (PangoFont *font, if (!fcfont->fontmap) return pango_font_metrics_new (); - info = g_new0 (PangoFcMetricsInfo, 1); + info = g_slice_new0 (PangoFcMetricsInfo); - fcfont->metrics_by_lang = g_slist_prepend (fcfont->metrics_by_lang, - info); + fcfont->metrics_by_lang = g_slist_prepend (fcfont->metrics_by_lang, info); info->sample_str = sample_str; diff --git a/pango/pangocairo-fcfontmap.c b/pango/pangocairo-fcfontmap.c index 188990b0..fe4780c2 100644 --- a/pango/pangocairo-fcfontmap.c +++ b/pango/pangocairo-fcfontmap.c @@ -195,7 +195,7 @@ pango_cairo_fc_font_map_init (PangoCairoFcFontMap *cffontmap) cffontmap->library = NULL; error = FT_Init_FreeType (&cffontmap->library); if (error != FT_Err_Ok) - g_error ("pango_cairo_font_map_init: Could not initialize freetype"); + g_critical ("pango_cairo_font_map_init: Could not initialize freetype"); cffontmap->dpi = 96.0; } diff --git a/pango/pangocairo-fontmap.c b/pango/pangocairo-fontmap.c index 2d0c8452..d5c55dac 100644 --- a/pango/pangocairo-fontmap.c +++ b/pango/pangocairo-fontmap.c @@ -219,7 +219,7 @@ free_context_info (PangoCairoContextInfo *info) if (info->merged_options) cairo_font_options_destroy (info->merged_options); - g_free (info); + g_slice_free (PangoCairoContextInfo, info); } static PangoCairoContextInfo * @@ -236,7 +236,7 @@ get_context_info (PangoContext *context, if (!info && create) { - info = g_new (PangoCairoContextInfo, 1); + info = g_slice_new (PangoCairoContextInfo); info->dpi = -1.0; info->set_options = NULL; info->surface_options = NULL; diff --git a/pango/pangocairo-win32font.c b/pango/pangocairo-win32font.c index 9e770691..d6a563be 100644 --- a/pango/pangocairo-win32font.c +++ b/pango/pangocairo-win32font.c @@ -165,7 +165,7 @@ static void free_metrics_info (PangoWin32MetricsInfo *info) { pango_font_metrics_unref (info->metrics); - g_free (info); + g_slice_free (PangoWin32MetricsInfo, info); } static void @@ -347,7 +347,7 @@ pango_cairo_win32_font_get_metrics (PangoFont *font, if (!win32font->fontmap) return pango_font_metrics_new (); - info = g_new0 (PangoWin32MetricsInfo, 1); + info = g_slice_new0 (PangoWin32MetricsInfo); cwfont->metrics_by_lang = g_slist_prepend (cwfont->metrics_by_lang, info); diff --git a/pango/pangofc-font.c b/pango/pangofc-font.c index b53dd5fa..953af1d6 100644 --- a/pango/pangofc-font.c +++ b/pango/pangofc-font.c @@ -112,7 +112,7 @@ static void free_metrics_info (PangoFcMetricsInfo *info) { pango_font_metrics_unref (info->metrics); - g_free (info); + g_slice_free (PangoFcMetricsInfo, info); } static void @@ -467,7 +467,7 @@ pango_fc_font_get_metrics (PangoFont *font, if (!fcfont->fontmap) return pango_font_metrics_new (); - info = g_new0 (PangoFcMetricsInfo, 1); + info = g_slice_new0 (PangoFcMetricsInfo); fcfont->metrics_by_lang = g_slist_prepend (fcfont->metrics_by_lang, info); diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c index 90c36955..8b395987 100644 --- a/pango/pangofc-fontmap.c +++ b/pango/pangofc-fontmap.c @@ -353,13 +353,13 @@ fontset_hash_key_free (FontsetHashKey *key) PANGO_FC_FONT_MAP_GET_CLASS (key->fontmap)->context_key_free (key->fontmap, key->context_key); - g_free (key); + g_slice_free (FontsetHashKey, key); } static FontsetHashKey * fontset_hash_key_copy (FontsetHashKey *old) { - FontsetHashKey *key = g_new (FontsetHashKey, 1); + FontsetHashKey *key = g_slice_new (FontsetHashKey); key->fontmap = old->fontmap; key->matrix = old->matrix; @@ -420,13 +420,13 @@ font_hash_key_free (FontHashKey *key) PANGO_FC_FONT_MAP_GET_CLASS (key->fontmap)->context_key_free (key->fontmap, key->context_key); - g_free (key); + g_slice_free (FontHashKey, key); } static FontHashKey * font_hash_key_copy (FontHashKey *old) { - FontHashKey *key = g_new (FontHashKey, 1); + FontHashKey *key = g_slice_new (FontHashKey); key->fontmap = old->fontmap; key->matrix = old->matrix; @@ -466,7 +466,7 @@ pango_fc_font_map_add_decoder_find_func (PangoFcFontMap *fcfontmap, PangoFcFontMapPrivate *priv = fcfontmap->priv; PangoFcFindFuncInfo *info; - info = g_new (PangoFcFindFuncInfo, 1); + info = g_slice_new (PangoFcFindFuncInfo); info->findfunc = findfunc; info->user_data = user_data; @@ -501,7 +501,7 @@ pango_fc_font_map_finalize (GObject *object) if (info->dnotify) info->dnotify (info->user_data); - g_free (info); + g_slice_free (PangoFcFindFuncInfo, info); priv->findfuncs = g_slist_delete_link (priv->findfuncs, priv->findfuncs); } @@ -1073,7 +1073,7 @@ pango_fc_font_map_get_patterns (PangoFontMap *fontmap, exit (1); } - patterns = g_new (PangoFcPatternSet, 1); + patterns = g_slice_new (PangoFcPatternSet); patterns->patterns = g_new (FcPattern *, font_patterns->nfont); patterns->n_patterns = 0; patterns->fontset = NULL; @@ -1167,7 +1167,7 @@ pango_fc_pattern_set_free (PangoFcPatternSet *patterns) FcPatternDestroy (patterns->patterns[i]); g_free (patterns->patterns); - g_free (patterns); + g_slice_free (PangoFcPatternSet, patterns); } static void diff --git a/pango/pangoft2-fontmap.c b/pango/pangoft2-fontmap.c index 69ebf2db..c0da2992 100644 --- a/pango/pangoft2-fontmap.c +++ b/pango/pangoft2-fontmap.c @@ -133,7 +133,7 @@ pango_ft2_font_map_new (void) error = FT_Init_FreeType (&ft2fontmap->library); if (error != FT_Err_Ok) - g_error ("pango_ft2_font_map_new: Could not initialize freetype"); + g_critical ("pango_ft2_font_map_new: Could not initialize freetype"); return (PangoFontMap *)ft2fontmap; } diff --git a/pango/pangoft2-render.c b/pango/pangoft2-render.c index c7713f69..965e8f63 100644 --- a/pango/pangoft2-render.c +++ b/pango/pangoft2-render.c @@ -96,7 +96,7 @@ static void pango_ft2_free_rendered_glyph (PangoFT2RenderedGlyph *rendered) { g_free (rendered->bitmap.buffer); - g_free (rendered); + g_slice_free (PangoFT2RenderedGlyph, rendered); } static PangoFT2RenderedGlyph * @@ -106,7 +106,7 @@ pango_ft2_font_render_glyph (PangoFont *font, PangoFT2RenderedGlyph *rendered; FT_Face face; - rendered = g_new (PangoFT2RenderedGlyph, 1); + rendered = g_slice_new (PangoFT2RenderedGlyph); face = pango_ft2_font_get_face (font); @@ -127,7 +127,7 @@ pango_ft2_font_render_glyph (PangoFont *font, rendered->bitmap_top = face->glyph->bitmap_top; } else - g_error ("Couldn't get face for PangoFT2Face"); + g_warning ("couldn't get face for PangoFT2Face, expect ugly output"); return rendered; } diff --git a/pango/pangoft2.c b/pango/pangoft2.c index 71abb41c..17dde11e 100644 --- a/pango/pangoft2.c +++ b/pango/pangoft2.c @@ -275,7 +275,7 @@ pango_ft2_font_get_glyph_info (PangoFont *font, if ((info == NULL) && create) { - info = g_new0 (PangoFT2GlyphInfo, 1); + info = g_slice_new0 (PangoFT2GlyphInfo); pango_fc_font_get_raw_extents (fcfont, ft2font->load_flags, glyph, @@ -378,7 +378,7 @@ pango_ft2_free_glyph_info_callback (gpointer key, if (font->glyph_cache_destroy && info->cached_glyph) (*font->glyph_cache_destroy) (info->cached_glyph); - g_free (value); + g_slice_free (PangoFT2GlyphInfo, info); return TRUE; } diff --git a/pango/pangowin32-fontcache.c b/pango/pangowin32-fontcache.c index fae691e3..1fd64e19 100644 --- a/pango/pangowin32-fontcache.c +++ b/pango/pangowin32-fontcache.c @@ -61,7 +61,7 @@ free_cache_entry (LOGFONT *logfont, if (!DeleteObject (entry->hfont)) PING (("DeleteObject for hfont %p failed", entry->hfont)); - g_free (entry); + g_slice_free (CacheEntry, entry); } /** @@ -82,6 +82,8 @@ pango_win32_font_cache_free (PangoWin32FontCache *cache) g_hash_table_destroy (cache->back); g_list_free (cache->mru); + + g_slice_free (PangoWin32FontCache, cache); } static guint @@ -127,7 +129,7 @@ pango_win32_font_cache_new (void) { PangoWin32FontCache *cache; - cache = g_new (PangoWin32FontCache, 1); + cache = g_slice_new (PangoWin32FontCache); cache->forward = g_hash_table_new (logfont_hash, logfont_equal); cache->back = g_hash_table_new (g_direct_hash, g_direct_equal); @@ -290,7 +292,7 @@ pango_win32_font_cache_load (PangoWin32FontCache *cache, if (!hfont) return NULL; - entry = g_new (CacheEntry, 1); + entry = g_slice_new (CacheEntry); entry->logfont = lf; entry->hfont = hfont; diff --git a/pango/pangoxft-font.c b/pango/pangoxft-font.c index 4a0c9819..2e26dbad 100644 --- a/pango/pangoxft-font.c +++ b/pango/pangoxft-font.c @@ -269,6 +269,12 @@ typedef struct } Extents; static void +extents_free (Extents *ext) +{ + g_slice_free (Extents, ext); +} + +static void get_glyph_extents_raw (PangoXftFont *xfont, PangoGlyph glyph, PangoRectangle *ink_rect, @@ -278,14 +284,14 @@ get_glyph_extents_raw (PangoXftFont *xfont, if (!xfont->glyph_info) xfont->glyph_info = g_hash_table_new_full (NULL, NULL, - NULL, (GDestroyNotify)g_free); + NULL, (GDestroyNotify)extents_free); extents = g_hash_table_lookup (xfont->glyph_info, GUINT_TO_POINTER (glyph)); if (!extents) { - extents = g_new (Extents, 1); + extents = g_slice_new (Extents); pango_fc_font_get_raw_extents (PANGO_FC_FONT (xfont), FT_LOAD_NO_BITMAP | FT_LOAD_NO_HINTING, diff --git a/pango/pangoxft-render.c b/pango/pangoxft-render.c index ea6c99ff..953db916 100644 --- a/pango/pangoxft-render.c +++ b/pango/pangoxft-render.c @@ -409,7 +409,7 @@ pango_xft_renderer_draw_glyph (PangoRenderer *renderer, double x, double y) { - g_error ("pango_xft_renderer_draw_glyph(): should not be called\n"); + g_critical ("pango_xft_renderer_draw_glyph(): should not be called"); } static void |