lkml.org 
[lkml]   [1997]   [Feb]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRE: B*gg*r mallocs, mmap JOY!


On Thu, 13 Feb 1997, John Carter wrote:

> Here is an example program for anyone else who wishes to use
> mmap. (Note you _can_ use mmap to write to files, the trick is
> ftruncate())
>
> cout << "Opened output file, now truncating file at " <<
> st.st_size / 1024 / 1024 << " Mb's.\n";
>
> ftruncate( ofd, st.st_size); // Note this cuty...
> // ftruncate is not in glibc, its a system call, and works instantaneously.

According to Stevens, "Advanced Programming in the UNIX Environment",
section 4.13 (can't give it more exact since I've got a translation), the
behaviour of ftruncate() is OS-dependant when the given length exceeds the
file's current size. It may or may not work. So if you want to write
portable code...

Christian


\
 
 \ /
  Last update: 2005-03-22 13:38    [from the cache]
©2003-2014 Jasper Spaans. Advertise on this site