Re: why declare non-ptr and pass with &?
- From: Raymond Wan <rwan cs mu oz au>
- To: Kang Jeong-Hee <Keizi mail co kr>
- Cc: gtk-list gnome org
- Subject: Re: why declare non-ptr and pass with &?
- Date: Tue, 5 Mar 2002 23:24:09 +1100 (EST)
On Tue, 5 Mar 2002, Kang Jeong-Hee wrote:
> in gtk-demo's tree_store.c source, each GtkTreeIter declared without *
> and passed with &. IMHO this is out of order comparing other objects
> and widgets. Is there specific reason why declare non-* and pass &?
Hi,
I haven't seen the source in question, but if you declared a
pointer to a structure, you would have to malloc and free it since it
would appear on the heap. If you declare it as normal and pass a
reference to it (&), then the space is created in the stack, when the
variable is declared and freed when the function exits.
Of course, I could be wrong as I frequently get "heap" and "stack"
mixed up (and am always too lazy to look it up myself :-) ).
Ray
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]