# HG changeset patch # User Richard Laager # Date 1138908932 0 # Node ID 5828d42e868442e3af0f9b1f6641ad29a182b50f # Parent 094d4b49e1c962fc5842fbbc946dab838eeb43f3 [gaim-migrate @ 15464] g_strdup() and free the label for a menu action. This way, if a plugin builds the label dynamically, we won't leak. committer: Tailor Script diff -r 094d4b49e1c9 -r 5828d42e8684 plugins/ChangeLog.API --- a/plugins/ChangeLog.API Thu Feb 02 19:17:49 2006 +0000 +++ b/plugins/ChangeLog.API Thu Feb 02 19:35:32 2006 +0000 @@ -244,6 +244,7 @@ * gaim_gtk_log_uninit() * gaim_url_fetch_request() * gaim_menu_action_new() + * gaim_menu_action_free() Signals - Changed: (See the Doxygen docs for details on all signals.) * Signal propagation now stops after a handler returns a non-NULL value. diff -r 094d4b49e1c9 -r 5828d42e8684 src/gtkutils.c --- a/src/gtkutils.c Thu Feb 02 19:17:49 2006 +0000 +++ b/src/gtkutils.c Thu Feb 02 19:35:32 2006 +0000 @@ -1739,6 +1739,6 @@ g_list_free(act->children); act->children = NULL; } - g_free(act); + gaim_menu_action_free(act); } } diff -r 094d4b49e1c9 -r 5828d42e8684 src/util.c --- a/src/util.c Thu Feb 02 19:17:49 2006 +0000 +++ b/src/util.c Thu Feb 02 19:35:32 2006 +0000 @@ -66,17 +66,26 @@ static char home_dir[MAXPATHLEN]; GaimMenuAction * -gaim_menu_action_new(char *label, GaimCallback callback, gpointer data, +gaim_menu_action_new(const char *label, GaimCallback callback, gpointer data, GList *children) { GaimMenuAction *act = g_new0(GaimMenuAction, 1); - act->label = label; + act->label = g_strdup(label); act->callback = callback; act->data = data; act->children = children; return act; } +void +gaim_menu_action_free(GaimMenuAction *act) +{ + g_return_if_fail(act != NULL); + + g_free(act->label); + g_free(act); +} + /************************************************************************** * Base16 Functions **************************************************************************/ diff -r 094d4b49e1c9 -r 5828d42e8684 src/util.h --- a/src/util.h Thu Feb 02 19:17:49 2006 +0000 +++ b/src/util.h Thu Feb 02 19:35:32 2006 +0000 @@ -60,6 +60,7 @@ /** * Creates a new GaimMenuAction. + * * @param label The text label to display for this action. * @param callback The function to be called when the action is used on * the selected item. @@ -68,9 +69,16 @@ * of the action. * @return The GaimMenuAction. */ -GaimMenuAction *gaim_menu_action_new(char *label, GaimCallback callback, +GaimMenuAction *gaim_menu_action_new(const char *label, GaimCallback callback, gpointer data, GList *children); +/** + * Frees a GaimMenuAction + * + * @param act The GaimMenuAction to free. + */ +void gaim_menu_action_free(GaimMenuAction *act); + /**************************************************************************/ /** @name Base16 Functions */ /**************************************************************************/