Re: GStrings and filestreams
- From: Soeren Sandmann <sandmann daimi au dk>
- To: Peter Jay Salzman <p dirac org>
- Cc: gtk-list gnome org
- Subject: Re: GStrings and filestreams
- Date: 28 Jul 2002 19:37:44 +0200
Peter Jay Salzman <p dirac org> writes:
> Right now, i need to get user input (stdin) or file input (FILE *) and
> put it into a char *. than copy the char * to a GString.
>
> It would be swell if I could do this in one atomic operation rather than
> the char * middleman, which may involve size checking and mallocing.
With glib 2.0 you could use g_string_set_size() to reserve a block of
memory that you can read into. E.g., use
g_string_set_size (str, str->len + BLOCK_SIZE)
to make sure that there is a block of size BLOCK_SIZE at the end of
the string that you can use. Then read into the memory pointed to by
str->str + str->len - BLOCK_SIZE.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]