Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail NNTP-Posting-Date: Wed, 25 Apr 2012 07:04:14 -0500 Message-ID: <4F97E841.C6B@mindspring.com> Date: Wed, 25 Apr 2012 08:04:17 -0400 From: pete Reply-To: pfiland@mindspring.com Organization: PF X-Mailer: Mozilla 3.04Gold (WinNT; I) MIME-Version: 1.0 Newsgroups: comp.lang.c Subject: Re: What standard library functions must deal with allocated memory? References: <4f9598df$0$20194$426a74cc@news.free.fr> <14459967.23.1335253094679.JavaMail.geo-discussion-forums@yndm3> Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Lines: 35 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 4.156.228.95 X-Trace: sv3-ck4klzl1a4itH8kq/qAv9kJzRj7von51JlZN0Tx4XJdDH+Kbo2C8zNA0RfQb8EzadRsZJWQ3sC35QWK!I4DkapfmhuWCiuyRX97qwuHIzqUe59h3TzMfGRLl2JujvjTkB8SICnBvm86ubQgfZmG79YzmgWMj!XjPwRn+y X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2448 X-Received-Bytes: 2589 Xref: csiph.com comp.lang.c:19900 Keith Thompson wrote: > > Malcolm McLean writes: > > בתאריך יום ש× י, 23 באפריל 2012 19:01:49 UTC+1, מאת Francois Grieu: > >> 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. > >> > > None of them, except for malloc(), realloc() and free() themselves. > > > > This appears to have been a deliberate design decision. > > strdup() is an > > obvious candidate for a library function, > > but including it would make > > the string library dependent on an allocation package > > being available. > > It wasn't a matter of depending on the availability of an allocation > package; *any* conforming hosted implementation > must provide malloc/free > and the functions declared in . > > I think the committee just felt it was a cleaner design. If strdup were to have been part of the standard library, it would have have made more sense to declare it in stdlib.h as one of the "Memory management functions", rather than to declare it in string.h. -- pete