diff options
author | Shaun McCance <shaunm@gnome.org> | 2009-06-18 21:19:08 -0500 |
---|---|---|
committer | Shaun McCance <shaunm@gnome.org> | 2009-06-18 21:27:55 -0500 |
commit | 8f5b8a651ee49de8ff49e395c17f1b2853819d58 (patch) | |
tree | 29a7e1c00824310198963eb1f9ce448d998f7e6a | |
parent | 13127b3769119d7caad8700a7b2bad5e8e75b8a8 (diff) | |
download | yelp-8f5b8a651ee49de8ff49e395c17f1b2853819d58.tar.gz |
Fixing memory management with params
I did this crazy thing long ago where every other string in the array way
const, and you had to use a custom free function. And somewhere along the
way, the custom free function got lost, and it rotted into something that
leaked half its memory and freed the other half twice. So we're just going
to go ahead and strdup and stop with the premature optimization.
-rw-r--r-- | src/yelp-db-print.c | 1 | ||||
-rw-r--r-- | src/yelp-docbook.c | 3 | ||||
-rw-r--r-- | src/yelp-info.c | 1 | ||||
-rw-r--r-- | src/yelp-mallard.c | 1 | ||||
-rw-r--r-- | src/yelp-man.c | 1 | ||||
-rw-r--r-- | src/yelp-settings.c | 4 | ||||
-rw-r--r-- | src/yelp-toc.c | 5 |
7 files changed, 11 insertions, 5 deletions
diff --git a/src/yelp-db-print.c b/src/yelp-db-print.c index 61d7d1c6..b85eea67 100644 --- a/src/yelp-db-print.c +++ b/src/yelp-db-print.c @@ -495,6 +495,7 @@ dbprint_process (YelpDbprint *dbprint) yelp_transform_start (priv->transform, priv->xmldoc, params); + g_strfreev (params); g_mutex_unlock (priv->mutex); done: diff --git a/src/yelp-docbook.c b/src/yelp-docbook.c index c7190e6b..b2f45d7b 100644 --- a/src/yelp-docbook.c +++ b/src/yelp-docbook.c @@ -496,7 +496,7 @@ docbook_process (YelpDocbook *docbook) params_max += 20; params = g_renew (gchar *, params, params_max); } - params[params_i++] = "db.chunk.max_depth"; + params[params_i++] = g_strdup ("db.chunk.max_depth"); params[params_i++] = g_strdup_printf ("%i", docbook->priv->max_depth); params[params_i] = NULL; @@ -504,6 +504,7 @@ docbook_process (YelpDocbook *docbook) yelp_transform_start (priv->transform, priv->xmldoc, params); + g_strfreev (params); g_mutex_unlock (priv->mutex); done: diff --git a/src/yelp-info.c b/src/yelp-info.c index dd8343c1..17a95c6c 100644 --- a/src/yelp-info.c +++ b/src/yelp-info.c @@ -419,6 +419,7 @@ info_process (YelpInfo *info) yelp_transform_start (priv->transform, priv->xmldoc, params); + g_strfreev (params); g_mutex_unlock (priv->mutex); done: diff --git a/src/yelp-mallard.c b/src/yelp-mallard.c index 65304a66..f372b885 100644 --- a/src/yelp-mallard.c +++ b/src/yelp-mallard.c @@ -546,6 +546,7 @@ mallard_page_data_run (MallardPageData *page_data) yelp_transform_start (page_data->transform, page_data->xmldoc, params); + g_strfreev (params); } static void diff --git a/src/yelp-man.c b/src/yelp-man.c index 542b4eb0..1e6fc562 100644 --- a/src/yelp-man.c +++ b/src/yelp-man.c @@ -481,6 +481,7 @@ man_process (YelpMan *man) yelp_transform_start (priv->transform, priv->xmldoc, params); + g_strfreev (params); g_mutex_unlock (priv->mutex); done: diff --git a/src/yelp-settings.c b/src/yelp-settings.c index 12137584..3aac2466 100644 --- a/src/yelp-settings.c +++ b/src/yelp-settings.c @@ -842,13 +842,13 @@ yelp_settings_params (gchar ***params, } for (colors_i = 0; colors_i < YELP_NUM_COLORS; colors_i++) { - (*params)[(*params_i)++] = (gchar *) color_params[colors_i]; + (*params)[(*params_i)++] = g_strdup ((gchar *) color_params[colors_i]); (*params)[(*params_i)++] = g_strdup_printf ("\"%s\"", yelp_settings_get_color (colors_i)); } for (icons_i = 0; icons_i < YELP_NUM_ICONS; icons_i++) { - (*params)[(*params_i)++] = (gchar *) icon_params[icons_i]; + (*params)[(*params_i)++] = g_strdup ((gchar *) icon_params[icons_i]); icon_info = yelp_settings_get_icon (icons_i); if (icon_info) { diff --git a/src/yelp-toc.c b/src/yelp-toc.c index b59a3150..201cabb4 100644 --- a/src/yelp-toc.c +++ b/src/yelp-toc.c @@ -504,10 +504,10 @@ toc_process (YelpToc *toc) info = gtk_icon_theme_lookup_icon (theme, "yelp-icon-big", 192, 0); if (info) { - params[params_i++] = "help_icon"; + params[params_i++] = g_strdup ("help_icon"); params[params_i++] = g_strdup_printf ("\"%s\"", gtk_icon_info_get_filename (info)); - params[params_i++] = "help_icon_size"; + params[params_i++] = g_strdup ("help_icon_size"); params[params_i++] = g_strdup_printf ("%i", gtk_icon_info_get_base_size (info)); gtk_icon_info_free (info); @@ -529,6 +529,7 @@ toc_process (YelpToc *toc) yelp_transform_start (priv->transform, priv->xmldoc, params); + g_strfreev (params); g_mutex_unlock (priv->mutex); done: |