This Trac instance is not used for development anymore!

We migrated our development workflow to git and Gitea.
To test the future redirection, replace trac by ariadne in the page URL.

Changeset 376 for ps


Ignore:
Timestamp:
06/03/04 02:27:50 (21 years ago)
Author:
janwas
Message:

implemented refcount for mmap

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ps/trunk/source/lib/res/file.cpp

    r373 r376  
    445445    CHECK_FILE(f);
    446446
     447    // make sure the mapping is actually freed,
     448    // regardless of how many references remain.
     449    if(f->map_refs > 1)
     450        f->map_refs = 1;
     451    file_unmap(f);
     452
    447453    // (check fd to avoid BoundsChecker warning about invalid close() param)
    448454    if(f->fd != -1)
     
    13451351    CHECK_FILE(f);
    13461352
     1353    // file is not currently mapped
     1354    if(f->map_refs == 0)
     1355        return -1;
     1356
     1357    // still more than one reference remaining - done.
     1358    if(--f->map_refs > 0)
     1359        return 0;
     1360
     1361    // no more references: remove the mapping
    13471362    void* const p = f->mapping;
    13481363    f->mapping = 0;
    1349     // don't reset size - the file is still open.
    1350 
    1351     // not currently mapped
    1352     if(!p)
    1353         return -1;
    1354 
    1355     return munmap(p, (uint)f->size);
    1356 }
     1364    // don't clear f->size - the file is still open.
     1365
     1366    return munmap(p, f->size);
     1367}
Note: See TracChangeset for help on using the changeset viewer.