D
Dann Corbit
Chris said:Barry Schwarz wrote:
At this point [where r is the result of a malloc() call] r contains
the address of a block of memory properly aligned for any possible
object.
Is there a portable way of finding out what this alignment is?
No. I consider this a flaw in the C standards.
If there *were* a portable way to find this, you could write portable
"augmented malloc and free" routines along the lines of those Mr Navia
has provided (with more work to deal with alignment, of course). ...
I think you mean to add a qualifier that pointers
can be turned into integers and operated on sensibly.
Otherwise knowing the alignment doesn't help.
Dumb question:
If we have no guarantee of modular math on the pointers, then why not
repeated subtraction on the pointers (which is clearly guaranteed)?