comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Counting Elements figured out.
Date: 03 Dec 2005 17:21:21 -0500
Date: 2005-12-03T17:21:21-05:00	[thread overview]
Message-ID: <wccwtilvn32.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: 0n3bl9hm6e.fsf@apal.ii.uib.no

gisle@apal.ii.uib.no (Gisle Sælensminde) writes:

> The mmap call will allocate in blocks, but it will always allocate at least
> as much as you ask for, so it's no problem to map 100 bytes with mmap.
> It is more likely that the OP did not set the mapped pages to be readable or
> writable, or that the file was actually shorter than the number of bytes 
> asked for. This (and more) will cause mmap to return "successfully", but 
> the process will fail when the memory is accesed. It's far fewer things 
> that can go wrong with malloc. In fact malloc may also have this 
> blockwise allocation property on many systems.

If you don't want to bother with files at all, which is likely,
you can mmap /dev/zero.

- Bob



      reply	other threads:[~2005-12-03 22:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <pan.2005.11.30.01.47.41.83657@nowhere.net>
2005-11-25 16:29 ` Counting Elements figured out David C. Hoos, Sr.
     [not found]   ` <pan.2005.11.30.23.15.25.917461@nowhere.net>
2005-12-02 23:09     ` Robert A Duff
2005-12-03 22:04       ` Gisle Sælensminde
2005-12-03 22:21         ` Robert A Duff [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox