Commit ae04e7e9 authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder

Plug leak.

2001-04-04  Morten Welinder  <terra@diku.dk>

	* ms-escher.c (ms_escher_blip_destroy): Plug leak.

	* ms-excel-util.c (lookup_font_base_char_width_new): Implement
 	negative caching.
parent 794f8dfc
......@@ -94,7 +94,7 @@ AC_SUBST(GNOMEGNORBA_LIBS)
dnl ******************************
dnl gnome-xml checking
dnl ******************************
AC_MSG_CHECKING(for libxml (aka gnome-xml) libraries 1.8.10 <= version < 2.0.0)
AC_MSG_CHECKING(for libxml (aka gnome-xml) libraries 1.8.10 <= version < 2.0.0 )
xml_ok=no
if xml-config --libs > /dev/null 2>&1; then
verstxt=`xml-config --version`
......
2001-04-04 Morten Welinder <terra@diku.dk>
* ms-escher.c (ms_escher_blip_destroy): Plug leak.
* ms-excel-util.c (lookup_font_base_char_width_new): Implement
negative caching.
2001-04-01 Jody Goldberg <jgoldberg@home.com>
* ms-obj.c (ms_obj_read_biff8_obj) : when reading the mystery trailing
......
......@@ -86,6 +86,7 @@ ms_escher_blip_destroy (MSEscherBlip *blip)
g_free (blip->raw_data);
blip->raw_data = NULL;
#endif
g_free (blip);
}
/*
......
......@@ -168,7 +168,8 @@ two_way_table_idx_to_key (const TwoWayTable *table, gint idx)
/***************************************************************************/
static GHashTable * xl_font_width_hash = NULL;
static GHashTable *xl_font_width_hash = NULL;
static GHashTable *xl_font_width_warned = NULL;
struct XL_font_width {
int const char_width_pts;
......@@ -261,11 +262,15 @@ init_xl_font_widths (void)
};
int i;
if (xl_font_width_hash == NULL)
if (xl_font_width_hash == NULL) {
xl_font_width_hash =
g_hash_table_new (&g_str_hash, &g_str_equal);
xl_font_width_warned =
g_hash_table_new (&g_str_hash, &g_str_equal);
}
g_return_if_fail (xl_font_width_hash != NULL);
g_assert (xl_font_width_hash != NULL);
g_assert (xl_font_width_warned != NULL);
for (i = 0; widths[i].name != NULL ; ++i)
g_hash_table_insert (xl_font_width_hash,
......@@ -273,12 +278,24 @@ init_xl_font_widths (void)
(gpointer)(widths+i));
}
static void
cb_destroy_xl_font_widths (gpointer key, gpointer value, gpointer user_data)
{
g_free (key);
}
void
destroy_xl_font_widths (void)
{
if (xl_font_width_hash) {
g_hash_table_destroy (xl_font_width_hash);
xl_font_width_hash = NULL;
g_hash_table_foreach (xl_font_width_warned,
cb_destroy_xl_font_widths,
NULL);
g_hash_table_destroy (xl_font_width_warned);
xl_font_width_warned = NULL;
}
}
......@@ -301,7 +318,7 @@ lookup_font_base_char_width_new (char const * const name, double size_pts,
size_pts /= 20.;
if (res != NULL) {
struct XL_font_width const * info = res;
float width = (is_default)
double width = (is_default)
? info->defaultchar_width_pts
: info->char_width_pts;
......@@ -324,7 +341,11 @@ lookup_font_base_char_width_new (char const * const name, double size_pts,
return width;
}
g_warning ("EXCEL : unknown widths for font '%s', guessing", name);
if (!g_hash_table_lookup (xl_font_width_warned, name)) {
char *namecopy = g_strdup (name);
g_warning ("EXCEL : unknown widths for font '%s', guessing", name);
g_hash_table_insert (xl_font_width_warned, namecopy, namecopy);
}
/* Use a rough heuristic for unknown fonts. */
return .5625 * size_pts;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment