A "malloc" question

Rey Paulo rvp at softserver.canberra.edu.au
Thu Apr 25 12:54:03 AEST 1991


Can anyone tell me if dynamically allocated storage for automatic variables
remains allocated even if the variables have already disappeared after the
invocation of the function.  If it is, does this mean that "automatic" does
not have any meaning at all for dynamically allocated storage?

And one more, if I have an automatic variable in a function and I allocate
storage for that variable using "malloc", are the following ways of freeing
the storage the same?  In both cases, assume the variable is (char *str).

   1) free (str)   -  inside the function where str is declared.

   2) free (sstr)  -  inside another function where sstr is declared but
                      made to point to str by a function call.

Thanx.
-- 
Rey V. Paulo                  | Internet:  rvp at csc.canberra.edu.au 
University of Canberra        | I am not bound to please thee with my answer. 
AUSTRALIA                     |         -Shylock, in "The Merchant of Venice" 
------------------------------+----------------------------------------------



More information about the Comp.unix.programmer mailing list