#include "ui/gui/psppire-encoding-selector.h"
-#include <assert.h>
#include <stdlib.h>
#include "libpspp/cast.h"
return hbox;
}
-/*
- Return a string describing the currently selected encoding.
+/*
+ Return a string describing the currently selected encoding.
The caller should free this string when no longer required.
*/
gchar *
psppire_encoding_selector_get_encoding (GtkWidget *selector)
{
gchar *encoding = NULL;
- GList *list, *pos;
+ GList *pos;
+ GList *list = gtk_container_get_children (GTK_CONTAINER (selector));
- list = gtk_container_get_children (GTK_CONTAINER (selector));
for (pos = list; pos; pos = pos->next)
{
GtkWidget *widget = pos->data;
break;
}
}
+
g_list_free (list);
- return encoding && !strcmp (encoding, "Auto") ? NULL : encoding;
+ if (encoding && (0 == strcmp (encoding, "Auto")))
+ {
+ g_free (encoding);
+ return NULL;
+ }
+
+ return encoding;
}