Messages in this thread | | | Date | Fri, 14 Feb 1997 23:37:27 +0100 (MET) | From | Christian Hardmeier <> | Subject | RE: 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
| |