Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: freeing pointers that are created in a function |
| Date | 2014-04-23 09:44 +1200 |
| Message-ID | <bro65kF43v1U2@mid.individual.net> (permalink) |
| References | <33316bf9-6341-4a32-88a6-b2d4360e4f57@googlegroups.com> |
G G wrote: > let's say, in a function, malloc or calloc is called to allocate > memory. the function returns a pointer to that allocated space. > > question: once the function ends the only pointer to the allocated > memory is that being assigned by the calling function. > > question: freeing the pointer being assigned to from the returning > function is the only one that needs to be freed in order to keep from > having a memory leak? [Please wrap your lines and remove the rubbish the awful google interface adds!] In short, yes. One allocation, one free. -- Ian Collins
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
freeing pointers that are created in a function G G <gdotone@gmail.com> - 2014-04-22 14:30 -0700 Re: freeing pointers that are created in a function James Kuyper <jameskuyper@verizon.net> - 2014-04-22 17:42 -0400 Re: freeing pointers that are created in a function Ian Collins <ian-news@hotmail.com> - 2014-04-23 09:44 +1200 Re: freeing pointers that are created in a function Kaz Kylheku <kaz@kylheku.com> - 2014-04-22 22:28 +0000 Re: freeing pointers that are created in a function G G <gdotone@gmail.com> - 2014-04-22 22:35 -0700
csiph-web