Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #106309
| From | James Kuyper <jameskuyper@verizon.net> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Parsing struct memory? |
| Date | 2017-03-16 22:09 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <oafgbr$4iv$1@dont-email.me> (permalink) |
| References | <62daf505-60e2-4dd5-b2c7-c619085dd548@googlegroups.com> <3c6dac5c-e381-448d-ab63-c6a1029dcd43@googlegroups.com> <ej0h6nFhe9iU8@mid.individual.net> |
On 03/16/2017 06:16 PM, Ian Collins wrote: > On 03/17/17 09:21 AM, Thiago Adams wrote: ... >> And how about aligned_alloc? Why do we need it? > > To allocate a block on some externally specified boundary, greater than > alignof(max_align_t). Unix (and no doubt windows) systems already have > system specific functions for doing this, such as getting a block of > memory aligned to a page boundary. "The value of alignment shall be a valid alignment supported by the implementation and the value of size shall be an integral multiple of alignment." (7.22.3.1p2) "Valid alignments include only those values returned by an _Alignof expression for fundamental types, plus an additional implementation-defined set of values, which may be empty." (6.2.8p4) By definition, for every type, _Alignof(type) <= _Alignof(max_align_t). Thus, all valid alignments greater than _Alignof(max_align_t) are implementation-defined, and there need not be any. If there are implementation-defined valid alignments greater _Alignof(max_align_t), aligned_alloc() certainly could be used for the purpose you describe. However, since there need not be any such alignments, I think it's more reasonable to assume that the primary purpose of aligned_alloc() is to allow the allocation of memory that is LESS strictly aligned than the memory allocated by malloc().
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Parsing struct memory? Thiago Adams <thiago.adams@gmail.com> - 2017-03-16 12:58 -0700
Re: Parsing struct memory? Thiago Adams <thiago.adams@gmail.com> - 2017-03-16 13:21 -0700
Re: Parsing struct memory? Ian Collins <ian-news@hotmail.com> - 2017-03-17 11:16 +1300
Re: Parsing struct memory? James Kuyper <jameskuyper@verizon.net> - 2017-03-16 22:09 -0400
Re: Parsing struct memory? Ian Collins <ian-news@hotmail.com> - 2017-03-17 15:23 +1300
Re: Parsing struct memory? David Brown <david.brown@hesbynett.no> - 2017-03-17 10:11 +0100
Re: Parsing struct memory? "James R. Kuyper" <jameskuyper@verizon.net> - 2017-03-17 11:35 -0400
Re: Parsing struct memory? gordonb.7zilv@burditt.org (Gordon Burditt) - 2017-03-16 20:17 -0500
Re: Parsing struct memory? James Kuyper <jameskuyper@verizon.net> - 2017-03-16 21:56 -0400
Re: Parsing struct memory? supercat@casperkitty.com - 2017-03-16 13:51 -0700
Re: Parsing struct memory? Lowell Gilbert <lgusenet@be-well.ilk.org> - 2017-03-16 19:39 -0400
Re: Parsing struct memory? BartC <bc@freeuk.com> - 2017-03-17 12:16 +0000
Re: Parsing struct memory? "Peter \"Shaggy\" Haywood" <phaywood@alphalink.com.au> - 2017-03-24 18:06 +1100
Re: Parsing struct memory? supercat@casperkitty.com - 2017-03-24 14:35 -0700
Re: Parsing struct memory? Keith Thompson <kst-u@mib.org> - 2017-03-16 19:14 -0700
Re: Parsing struct memory? scott@slp53.sl.home (Scott Lurndal) - 2017-03-17 12:45 +0000
Re: Parsing struct memory? scott@slp53.sl.home (Scott Lurndal) - 2017-03-17 12:41 +0000
Re: Parsing struct memory? Thiago Adams <thiago.adams@gmail.com> - 2017-03-17 08:17 -0700
Re: Parsing struct memory? Thiago Adams <thiago.adams@gmail.com> - 2017-03-20 05:07 -0700
csiph-web