Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Dr Nick <3-nospam@temporary-address.org.uk> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: What standard library functions must deal with allocated memory? |
| Date | 2012-04-24 07:05 +0100 |
| Message-ID | <87lilld5r2.fsf@temporary-address.org.uk> (permalink) |
| References | <4f9598df$0$20194$426a74cc@news.free.fr> <dj8bp7tjbhb1i2d67rnh5qviqf9t2ptetu@4ax.com> <4f95c71f$0$1734$426a34cc@news.free.fr> <jn516a$3tb$1@dont-email.me> <slrnjpc2mf.n2f.nospam@nospam.invalid> |
Quentin Pope <nospam@nospam.invalid> writes: > On 24 Apr 2012 at 1:55, Eric Sosman wrote: >> On 4/23/2012 5:18 PM, Francois Grieu wrote: >>>> On Mon, 23 Apr 2012 20:01:49 +0200, Francois Grieu<fgrieu@gmail.com> >>>> wrote: >>>>> If strdup was a standard function (it is not), it would be in my list. > <snip> >>> It would interest me because one can not implement strdup without calling >>> calloc malloc realloc (since the result must be a valid argument to free). >> >> When did strdup() appear in the Standard library? I don't have >> the actual Standard, but strdup() is absent from the ISO/IEC 9899:201x >> draft of 2011-04-12. > > Why deliberately misrepresent people Eric? Francois said right at the > start that he knows strdup is not standard. > > In fact I think he is wrong for another reason. Pointers from malloc > needed to be aligned for all types: a library strdup() function could > potentially use an unaligned malloc-like function as long as the data > structure was still compatible with free(). I /think/ it could use something else entirely as long as the pointer so generated had a magic value that free() could recognise. So strdup could allocate from an entirely separate pool or pools and free knows the bounds of any such pools and so knows what do with it. Could be useful if the use pattern is lots and lots of roughly equal sized allocations and frees. It would need to do some undefined stuff in checking pointers against each other to know, but it's part of the implementation and so allowed to do this. Am I right? -- Online waterways route planner | http://canalplan.eu Plan trips, see photos, check facilities | http://canalplan.org.uk
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
What standard library functions must deal with allocated memory? Francois Grieu <fgrieu@gmail.com> - 2012-04-23 20:01 +0200
Re: What standard library functions must deal with allocated memory? James Kuyper <jameskuyper@verizon.net> - 2012-04-23 14:17 -0400
Re: What standard library functions must deal with allocated memory? Francois Grieu <fgrieu@gmail.com> - 2012-04-23 20:37 +0200
Re: What standard library functions must deal with allocated memory? Barry Schwarz <schwarzb@dqel.com> - 2012-04-23 12:26 -0700
Re: What standard library functions must deal with allocated memory? Keith Thompson <kst-u@mib.org> - 2012-04-23 14:04 -0700
Re: What standard library functions must deal with allocated memory? Robert Wessel <robertwessel2@yahoo.com> - 2012-04-23 17:15 -0500
Re: What standard library functions must deal with allocated memory? Francois Grieu <fgrieu@gmail.com> - 2012-04-23 23:18 +0200
Re: What standard library functions must deal with allocated memory? Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-04-23 21:55 -0400
Re: What standard library functions must deal with allocated memory? Quentin Pope <nospam@nospam.invalid> - 2012-04-24 02:07 +0000
Re: What standard library functions must deal with allocated memory? Dr Nick <3-nospam@temporary-address.org.uk> - 2012-04-24 07:05 +0100
Re: What standard library functions must deal with allocated memory? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-04-24 00:38 -0700
Re: What standard library functions must deal with allocated memory? Keith Thompson <kst-u@mib.org> - 2012-04-24 22:24 -0700
Re: What standard library functions must deal with allocated memory? pete <pfiland@mindspring.com> - 2012-04-25 08:04 -0400
Re: What standard library functions must deal with allocated memory? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-04-28 04:09 -0700
Re: What standard library functions must deal with allocated memory? Stephen Sprunk <stephen@sprunk.org> - 2012-04-25 01:19 -0500
Re: What standard library functions must deal with allocated memory? pete <pfiland@mindspring.com> - 2012-04-25 07:55 -0400
Re: What standard library functions must deal with allocated memory? gordonb.ho66c@burditt.org (Gordon Burditt) - 2012-04-27 20:44 -0500
csiph-web