Re: gtk_object_set_data (GList)?
- From: Sven Neumann <sven gimp org>
- To: "AndrXs" Giraldo <andres_giraldo yahoo com>
- Cc: Paul Davis <pbd Op Net>, Gtk List <gtk-list gnome org>
- Subject: Re: gtk_object_set_data (GList)?
- Date: 12 Jul 2001 17:10:43 +0200
Hi,
"AndrXs" Giraldo <andres_giraldo yahoo com> writes:
> typedef _data
> {
> char *string;
> int value;
> } data;
>
> data comboitem;
>
> GList *liste = NULL;
>
> > comboitem = g_malloc(sizeof(struct _data));
> > strcpy(comboitem.string, "toto");
> > liste = g_list_insert(liste, comboitem, 0);
> >
> > comboitem = g_malloc(sizeof(struct _data));
> > strcpy(comboitem.string, "tata");
> > liste = g_list_insert(liste, comboitem, 0);
this code should probably read:
typedef struct _data
{
char *string;
int value;
} data;
data *comboitem;
GList *liste = NULL;
comboitem = g_new (data, 1);
comboitem->string = g_strdup ("toto");
liste = g_list_prepend (liste, comboitem);
comboitem = g_new (data, 1);
comboitem->string = g_strdup ("tata");
liste = g_list_prepend (liste, comboitem);
don't forget to free your strings again (using g_free).
Salut, Sven
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]