malloc on IRIX System V
David B. Anderson
davea at quasar.wpd.sgi.com
Fri Jan 5 09:08:47 AEST 1990
In article <9001041731.AA03346 at acf8.NYU.EDU> kalvina at ACF8.NYU.EDU (Alan Kalvin) writes:
>
>If malloc is used to allocate an amount of memory greater or equal to
>the system page size, will the memory returned will be page-aligned?
No, not by default. And not with the libc.a malloc.
>If not, is it possible to force page-alignment?
Look at the mallinfo man page (M_GRAIN particularly). Appropriately
configured and used, the malloc in libmalloc.a will do what you want.
Regards,
[ David B. Anderson Silicon Graphics (415)335-1548 davea at sgi.com ]
PS:
The traditional (before mallinfo()) way to do this is to
a) malloc 1 page more than is needed.
b) adjust the returned pointer (upwards) to the nearest page boundary.
The extra space is ``wasted''. Moreover, the adjusted pointer cannot
be used in a free(3) call (only the original pointer can be used with free() ).
More information about the Comp.sys.sgi
mailing list