Re: Bug in GLib, libglade, libc?? (ok, =?ISO-8859-1?Q?it=B4s_n?= =?ISO-8859-1?Q?ot_GTK_specific=2E=2E=2E=29?=
- From: Fabricio Rocha <rocha_fabricio yahoo com br>
- To: gtk-app-devel-list gnome org
- Subject: Re: Bug in GLib, libglade, libc?? (ok, it´s not GTK specific...)
- Date: Wed, 16 Aug 2006 01:02:58 -0300
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/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]