Re: Declaring objects on the stack
- From: Havoc Pennington <hp redhat com>
- To: Marc Tardif <intmktg cam org>
- Cc: gtk-list gnome org
- Subject: Re: Declaring objects on the stack
- Date: 25 Apr 2002 10:34:17 -0400
Marc Tardif <intmktg cam org> writes:
> Is there a way to declare a GString object on the stack and then pass a
> reference to that object to an initialization method? For example:
>
> GString str, *ptr;
> ptr = g_string_assign(&str, "foo");
>
> Of course, I realize that the above is not valid because g_string_assign
> expects cooked values in &str whereas values declared on the stack are likely
> to contain garbage. So is there some other method which has the purpose of
> initializing &str without allocating memory for the object on the heap?
>
Nope. The actual size of a GString exceeds sizeof(GString), look at
gstring.c implementation code.
Havoc
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]