Commit 524ce829 authored by Mike Hommey's avatar Mike Hommey
Browse files

Bug 686805 part 1 - Make Mappable::munmap, Mappable1stPagePtr::munmap and...

Bug 686805 part 1 - Make Mappable::munmap, Mappable1stPagePtr::munmap and MappedPtr::munmap private. r=tglek
parent 15f1a573
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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;
};

+1 −1
Original line number Diff line number Diff line
@@ -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

+6 −0
Original line number Diff line number Diff line
@@ -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.
   */
+2 −0
Original line number Diff line number Diff line
@@ -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);