From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,2808111f01d47bd3 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,UTF8 Path: g2news1.google.com!news4.google.com!newsfeed2.dallas1.level3.net!news.level3.com!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Counting Elements figured out. Date: 03 Dec 2005 17:21:21 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <0n3bl9hm6e.fsf@apal.ii.uib.no> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: pcls4.std.com 1133648481 19255 192.74.137.71 (3 Dec 2005 22:21:21 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Sat, 3 Dec 2005 22:21:21 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news1.google.com comp.lang.ada:6732 Date: 2005-12-03T17:21:21-05:00 List-Id: 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