Re: multiple calls to g_io_channel_read_line and g_free question
- From: Olivier Sessink <lists olivier pk wau nl>
- 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 15:06:17 +0200
Colossus wrote:
[..]
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 ?
see
http://developer.gnome.org/doc/API/2.0/glib/glib-IO-Channels.html#g-io-channel-read-line
"Reads a line, including the terminating character(s), from a GIOChannel
into a newly-allocated string."
"newly allocated string" means that for every call to
g_io_channel_read_line() new memory is allocated, so for every call you
have to free the string.
regards,
Olivier
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]