Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!ames!sgi!davea@quasar.wpd.sgi.com From: davea@quasar.wpd.sgi.com (David B. Anderson) Newsgroups: comp.sys.sgi Subject: Re: malloc on IRIX System V Message-ID: <47469@sgi.sgi.com> Date: 4 Jan 90 22:08:47 GMT References: <9001041731.AA03346@acf8.NYU.EDU> Sender: davea@quasar.wpd.sgi.com Reply-To: davea@quasar.UUCP (David B. Anderson) Organization: Silicon Graphics, Inc., Mountain View, CA Lines: 22 In article <9001041731.AA03346@acf8.NYU.EDU> kalvina@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@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() ).