RE: reading GIOChannel causes "Segmentation fault"



Hi Sven,

You may have already noticed this, but ...

[snip]
(056)       gboolean parseText(GIOChannel *source, GIOCondition condition,
                       gpointer client) {
    (057)         uint *readBytes = 0;
    (058)         char buffer[4096];
..
(064)         g_io_channel_read(source, buffer, 1, readBytes);
..
(071)         return false;
(072)       }
[snip]

Changed it to the prevous (remember this is c++). All values are
initialized.
it's still segfaulting.
Does anyone have example code? (i'm getting weird)

I would change the above to;
        guint readBytes = 0;
        ...
        g_io_channel_read( source, buffer, 1, &readBytes );

Refer to the following web page and you will see that the function signature
for "g_io_channel_read()" take a pointer to an integer, meaning that it is
(in this case) going to update the memory (an integer) at the address you
pass in. Therefore, you need to ensure that you actually pass a pointer to
static/auto or allocated memory, rather than merely a NULL pointer (which
doesn't point to any kind of allocated memory).
    http://developer.gnome.org/doc/API/glib/glib-io-channels.html

Hope this at least helps you a little on your quest.

Tim.
_________________________________________________
Tim R. Betts
Senior Programmer/Analyst
wmsVision, Inc. (http://www.wmsvision.com)
E-mail: mailto:tbetts goissi com






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]