Re: why declare non-ptr and pass with &?

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 &? 


	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 :-) ).


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]