Bug 686805 part 1 - Make Mappable::munmap, Mappable1stPagePtr::munmap and MappedPtr::munmap private. r=tglek

This commit is contained in:
Mike Hommey 2012-02-22 08:12:15 +01:00
parent b07c58481d
commit 826e3fb405
4 changed files with 12 additions and 2 deletions

View File

@ -86,10 +86,12 @@ public:
, mappable(mappable)
{ }
private:
friend class GenericMappedPtr<Mappable1stPagePtr>;
void munmap(void *buf, size_t length) {
mappable->munmap(buf, length);
}
private:
Mappable *mappable;
};

View File

@ -206,7 +206,7 @@ public:
#ifdef ANDROID
~_MappableBuffer() {
/* Free the additional page we allocated. See _MappableBuffer::Create */
munmap(this + ((GetLength() + PAGE_SIZE) & ~(PAGE_SIZE - 1)), PAGE_SIZE);
::munmap(this + ((GetLength() + PAGE_SIZE) & ~(PAGE_SIZE - 1)), PAGE_SIZE);
}
#endif

View File

@ -26,10 +26,16 @@ public:
virtual void *mmap(const void *addr, size_t length, int prot, int flags,
off_t offset) = 0;
private:
virtual void munmap(void *addr, size_t length) {
::munmap(addr, length);
}
/* Limit use of Mappable::munmap to classes that keep track of the address
* and size of the mapping. This allows to ignore ::munmap return value. */
friend class Mappable1stPagePtr;
public:
/**
* Indicate to a Mappable instance that no further mmap is going to happen.
*/

View File

@ -247,6 +247,8 @@ struct MappedPtr: public GenericMappedPtr<MappedPtr>
: GenericMappedPtr<MappedPtr>(buf, length) { }
MappedPtr(): GenericMappedPtr<MappedPtr>() { }
private:
friend class GenericMappedPtr<MappedPtr>;
void munmap(void *buf, size_t length)
{
::munmap(buf, length);