Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!nntp.club.cc.cmu.edu!feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: James Kuyper Newsgroups: comp.lang.c Subject: Re: What standard library functions must deal with allocated memory? Date: Mon, 23 Apr 2012 14:17:55 -0400 Organization: A noiseless patient Spider Lines: 15 Message-ID: <4F959CD3.60701@verizon.net> References: <4f9598df$0$20194$426a74cc@news.free.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Injection-Info: mx04.eternal-september.org; posting-host="2P71cupDoazVVolqpw1jrw"; logging-data="11484"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/u4agOD9ni7H6/lUbTQwj2dVvxl+WnPFs=" User-Agent: Mozilla/5.0 (X11; Linux i686; rv:9.0) Gecko/20111220 Thunderbird/9.0 In-Reply-To: <4f9598df$0$20194$426a74cc@news.free.fr> Cancel-Lock: sha1:yL5QOAEK8Rab9j1i9s9/10PBr4A= Xref: csiph.com comp.lang.c:19840 On 04/23/2012 02:01 PM, Francois Grieu wrote: > I'm trying to list all the standard C99/C2011 library functions that, by > design, must deal with allocated memory in any way. > > I've seen calloc malloc realloc free. Is there any other? > If strdup was a standard function (it is not), it would be in my list. In C2011, add aligned_alloc(). Otherwise, your list is complete. Note that the rules for fopen() and fclose() are written in such a way that the FILE* objects they return, or the buffers managed by those objects, could be dynamically allocated, though not necessarily by the malloc() family. The behavior is undefined if you make any use of a FILE* returned by fopen(), after it has been passed to fclose(), as would naturally be the case if it were allocated by a call to malloc().