Mail Archives: djgpp/1997/07/31/09:33:21
In article <1 DOT 5 DOT 4 DOT 16 DOT 19970727141631 DOT 54172988 AT giasbga DOT vsnl DOT net DOT in>,
chirayu AT radiolink DOT net says...
Not really following the thread, but I'm pretty sure it returns the two
aligned, not the power-of-two aligned. Maybe even the four-aligned. This is
to speed memory acesses, since even mem addresses work about twice as fast
as odd, or at least they used to, and just about the same holds true for
those divisible by 2 and 4. AFIAK, anyways... Oh, this should be fairly
standard across all compilers. Incidently, for this same reason it is a good
idea to place larger datatypes (ints/shorts) at the beginning of a data
structure, and the smaller ones at the end (shorts/bytes). Should speed
things up. OH! Yes, and I think that gcc may even optimize things this way,
so that for instance if you use inheritance it will padd the existing
structure to a 4-aligned -- but i'm guessing here so I should prolly just
shut up while i'm still probably right! No need for concern, at any rate...
- Calvin -
>>But that's NOT correct. malloc() returns also the power of two aligned
>>block to the user.
>
>Now that is sheer wasting of memory. I think its a very bad idea to have
>implememnted it this way (the malloc()). Do the other compilers (watcom,
>visual c++, symantec etc) do the same?
- Raw text -