Portablity using structures and malloc - Help

John P. Linderman jpl at allegra.UUCP
Sun Jul 21 03:21:09 AEST 1985


> The answer is simple: malloc has been written by someone who knows
> the hardware alignment constraints of the machine, and it returns
> a pointer that is aligned for *any* use.
> 
> In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251)

malloc knows, but it's a pity that you can't make malloc tell.
If there were a nice

    int malign() {return ALIGNMENT_MULTIPLE;}

entry in the malloc package, I could do my own storage allocation out
of an area acquired from malloc or elsewhere.  [I might want to do this
so I could allocate variable-length structures from both ends of an area
until the area was filled, something malloc itself cannot be made to do.]
A totally trivial one-liner that would make it much easier to write
portable software.  How about it, system implementors?

John P. Linderman     The much-maligned allegra!jpl



More information about the Comp.unix mailing list