Is this a bug in the GIOChannel g_io_channel_write_chars() function?
- From: Jeff Franks <jcf tpg com au>
- To: gtk-devel-list gnome org
- Subject: Is this a bug in the GIOChannel g_io_channel_write_chars() function?
- Date: Thu, 13 Nov 2003 01:57:32 +1100
Hi,
I'm trying to use the GLib mainloop-test example and came across this
problem. Is it a bug?
In mainloop-test.c in the GLIb tests directory the following function works:
gboolean
write_all (GIOChannel *channel, char *buf, gsize len)
{
gsize bytes_written = 0;
gsize count;
GIOError err;
while (bytes_written < len)
{
err = g_io_channel_write (channel, buf + bytes_written, len -
bytes_written, &count);
if (err && err != G_IO_ERROR_AGAIN)
return FALSE;
bytes_written += count;
}
return TRUE;
}
However g_io_channel_write() is deprecated. When I repalce it with
g_io_channel_write_chars() and update the code appropriately, to this:
gboolean
write_all (GIOChannel *channel, char *buf, gsize len)
{
gsize bytes_written = 0;
gsize count;
GIOStatus status;
while (bytes_written < len)
{
status = g_io_channel_write_chars (channel, buf + bytes_written,
len - bytes_written, &count, NULL);
if (status != G_IO_STATUS_AGAIN)
return FALSE;
bytes_written += count;
}
return TRUE;
}
It does not work. instead you get this compiler error:
GLib-ERROR **: file giochannel.c: line 2113 (g_io_channel_write_chars):
should not be reached
aborting...
Trace/breakpoint trap
I've tried to trace what is happening but g_io_channel_write_chars() is
a very big function.
Any ideas,
Jeff Franks.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]