Path: utzoo!utgpu!watserv1!watmath!att!att!linac!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!wuarchive!cs.utexas.edu!uunet!munnari.oz.au!sirius.ucs.adelaide.edu.au!adelphi.ua.oz.au!mferrare From: mferrare@adelphi.ua.oz.au (Mark Ferraretto) Newsgroups: comp.lang.c Subject: scope of malloc Message-ID: <1791@sirius.ucs.adelaide.edu.au> Date: 7 Nov 90 02:24:49 GMT Sender: news@ucs.adelaide.edu.au Reply-To: mferrare@adelphi.ua.oz.au (Mark Ferraretto) Organization: Department of Physics, University of Adelaide, South Australia Lines: 20 Nntp-Posting-Host: adelphi.ua.oz.au You see, I have this question... When malloc is called in a function and the scope of the pointer is only that function is the memory deallocated when the pointer is (ie on exit of the function?) deallocated? Or does that chunk of memory hang around util the program terminates? I am calling several functions that involve a lot of dynamic memory allocation most of which is only relevant to the scope of the function where the memory is allocated. These functions get called repeatedly. So do I need to fill these functions to include free() calls with at the end of each function? System: SunOS 4.0.3, NewsOS compiler: cc (came with os in all cases) machines: sun4/280 sun3/60, News1580, News3410 (coming soon) Thanks for your help. Please e-mail to me as I don't usually read this newsgroup. Mark Ferraretto mferrare@physics.adelaide.edu.au _ Name : Mark Ferraretto \ \ Place : Department of Physics and Mathematical Physics || \ \ University of Adelaide ==========>==>==-- Aarnet: mferrare@physics.adelaide.edu.au