Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b618576f authored by Mark Salyzyn's avatar Mark Salyzyn
Browse files

libutils: FileMap styling adjustments

Change-Id: I487ebe67a46a7b8f680e722141dd216bbd396f3e
parent 15085a6a
Loading
Loading
Loading
Loading
+26 −35
Original line number Diff line number Diff line
@@ -40,19 +40,14 @@ using namespace android;

/*static*/ long FileMap::mPageSize = -1;


/*
 * Constructor.  Create an empty object.
 */
// Constructor.  Create an empty object.
FileMap::FileMap(void)
    : mRefCount(1), mFileName(NULL), mBasePtr(NULL), mBaseLength(0),
      mDataPtr(NULL), mDataLength(0)
{
}

/*
 * Destructor.
 */
// Destructor.
FileMap::~FileMap(void)
{
    assert(mRefCount == 0);
@@ -81,14 +76,12 @@ FileMap::~FileMap(void)
}


/*
 * Create a new mapping on an open file.
 *
 * Closing the file descriptor does not unmap the pages, so we don't
 * claim ownership of the fd.
 *
 * Returns "false" on failure.
 */
// Create a new mapping on an open file.
//
// Closing the file descriptor does not unmap the pages, so we don't
// claim ownership of the fd.
//
// Returns "false" on failure.
bool FileMap::create(const char* origFileName, int fd, off64_t offset, size_t length,
        bool readOnly)
{
@@ -143,7 +136,7 @@ bool FileMap::create(const char* origFileName, int fd, off64_t offset, size_t le
    assert(offset >= 0);
    assert(length > 0);

    /* init on first use */
    // init on first use
    if (mPageSize == -1) {
#if NOT_USING_KLIBC
        mPageSize = sysconf(_SC_PAGESIZE);
@@ -152,7 +145,7 @@ bool FileMap::create(const char* origFileName, int fd, off64_t offset, size_t le
            return false;
        }
#else
        /* this holds for Linux, Darwin, Cygwin, and doesn't pain the ARM */
        // this holds for Linux, Darwin, Cygwin, and doesn't pain the ARM
        mPageSize = 4096;
#endif
    }
@@ -181,7 +174,7 @@ try_again:
        return false;
    }
    mBasePtr = ptr;
#endif /* HAVE_POSIX_FILEMAP */
#endif // HAVE_POSIX_FILEMAP

    mFileName = origFileName != NULL ? strdup(origFileName) : NULL;
    mBaseLength = adjLength;
@@ -197,9 +190,7 @@ try_again:
    return true;
}

/*
 * Provide guidance to the system.
 */
// Provide guidance to the system.
int FileMap::advise(MapAdvice advice)
{
#if HAVE_MADVISE