[lkml]   [1997]   [Feb]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    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...


     \ /
      Last update: 2005-03-22 13:38    [W:0.017 / U:6.068 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site