Re: multiple calls to g_io_channel_read_line and g_free question
- From: Tristan Van Berkom <tvb gnome org>
- To: Colossus <colossus 3000 it>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: multiple calls to g_io_channel_read_line and g_free question
- Date: Tue, 18 Oct 2005 10:30:05 -0400
Colossus wrote:
Hi,
I have a doubt. I call g_io_channel_read_line several times this way:
g_io_channel_read_line ( ioc, &line, NULL, NULL, NULL );
//do some things on line
//shall I g_free (line) here ?
g_io_channel_read_line ( ioc, &line, NULL, NULL, NULL );
//ecc
My doubt is: shall I free line before the second call to
g_io_channel_read_line or I can call g_free ONCE when I don't need to
read anymore ?
This doc says:
http://developer.gnome.org/doc/API/2.0/glib/glib-IO-Channels.html#g-io-channel-read-line
"str_return will contain allocated memory if the return is
G_IO_STATUS_NORMAL"
That means every time g_io_channel_read_line is successfull; you
have some newly allocated memory.
It is up to you to free that memory, yes.
Cheers,
-Tristan
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]