OK, Your pointer code is all screwed up :-) g_strdup already allocates memory so you don't need to do g_malloc before it, just g_strdup_printf right into your variable. Also, your getting a segfault because you're dereferencing the pointer where the pointer itself is expected (when setting GtkEntry for example). Try dropping the * and see if that works.
Samuel On 8/15/06, Fabricio Rocha <[EMAIL PROTECTED]> wrote: > Hello, guys! > > Sorry, I know i´m crossing the borders of off-topic. But I had to tell > you that I could get rid of SEGFAULTs by using a GPtrArray* as member of > my structure. As said before, this struct member shall hold one or more > strings. (John, I have tried using a GList as this member, but I could > not get it working as well. Maybe it was a erroneus attempt, however). > > I just got curious about WHAT is the "magic" in GPtrArray that I could > not "reproduce" using a gchar** variable. Man, I REALLY tried it, but > you masters should be able to explain... My last attempt was that: the > struct variable is called "var", the list of strings is the member > "values". So, var->values was recognised by GDB as "gchar*[0]", and > *var->values was recognised as "gchar*". You will probably find it very > naive and exaggerated, but just realise the desperation: > > ------------------------- > gchar *valuearea; > gchar *tempvalue; > VarInfo newvar; > > tempvalue = g_strdup_printf ("variable%i",++varscount); > valuearea = (gchar*)g_malloc ((gulong)strlen(tempvalue)); > valuearea = g_strdup (tempvalue); > newvar.name = valuearea; > (...) > valuearea = (gchar*) g_malloc (strlen(tempvalue=g_strdup("0"))); > valuearea = g_strdup(tempvalue); > *newvar.values = valuearea; > newvar.parentvar = NULL; > > var = g_malloc ((gulong)sizeof(newvar)); > var = memcpy ((VarInfo*)var, (VarInfo*)&newvar, sizeof(newvar)); > ----------------------- > > I still don´t know what the hell I did wrong. Later in the code, I > could access and use correctly "var->name", but I would get SEGFAULT in > a line that a tried to set the text of a GtkEntry to *(var->values). GDB > would tell me that it couldn´t access address 0x11 (TOO low address > indeed). What was wrong there, gurus?? > > By the way, I´m pretty happy that it´s working fine with GPtrArray. > But > I can´t stop itching my head until I found out what I was doing wrong.... :) > > Thank you all, very much! > > Fabricio Rocha > Brasilia, Brasil > > > _______________________________________________________ > Novidade no Yahoo! Mail: receba alertas de novas mensagens no seu celular. > Registre seu aparelho agora! > http://br.mobile.yahoo.com/mailalertas/ > > > _______________________________________________ > gtk-app-devel-list mailing list > gtk-app-devel-list@gnome.org > http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list