Re: [gtk-list] GList and Combo
- From: Paolo Molaro <lupus lettere unipd it>
- To: "gtk-list redhat com" <gtk-list redhat com>
- Subject: Re: [gtk-list] GList and Combo
- Date: Thu, 14 May 1998 11:20:57 +0200
On Thu, May 14, 1998 at 10:54:18AM +0200, Marc Aubry wrote:
GList* select_sizes (void)
{
guint i;
gchar *size;
GList *sizelist = NULL;
size = (char *) calloc (2, sizeof(char));
for (i=1; i<=5; i++)
{
sprintf (size, "%d", i);
- sizelist = g_list_append (sizelist, size);
+ sizelist = g_list_append (sizelist, g_strdup(size));
} /* end_for */
- sizelist = g_list_append (sizelist, "end");
+ sizelist = g_list_append (sizelist, g_strdup("end"));
return sizelist;
}
In your example you were building a GList with the same data in
every slot:-).
Remember to free the strings when you're done (and the glist) with
something like g_list_foreach(sizelist, g_free, NULL).
lupus
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]