From 518b99b9672c28c94c8caa5f8007c60faebcc847 Mon Sep 17 00:00:00 2001 From: mandreyel Date: Mon, 27 May 2019 18:38:27 +0200 Subject: [PATCH] Fix offset method name to reflect actual intent It was meant to return the mapping offset from the start of the file, but in reality it returned the mapping offset from the start of the page that is mapped. It is now renamed to reflect this. --- include/mio/mmap.hpp | 14 +++++++------- include/mio/shared_mmap.hpp | 6 ------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/include/mio/mmap.hpp b/include/mio/mmap.hpp index ddb95b2..def559a 100644 --- a/include/mio/mmap.hpp +++ b/include/mio/mmap.hpp @@ -180,11 +180,11 @@ public: size_type length() const noexcept { return length_; } size_type mapped_length() const noexcept { return mapped_length_; } - /** - * Returns the offset, relative to the file's start, at which the mapping was - * requested to be created. - */ - size_type offset() const noexcept { return mapped_length_ - length_; } + /** Returns the offset relative to the start of the mapping. */ + size_type mapping_offset() const noexcept + { + return mapped_length_ - length_; + } /** * Returns a pointer to the first requested byte, or `nullptr` if no memory mapping @@ -362,12 +362,12 @@ private: typename = typename std::enable_if::type > pointer get_mapping_start() noexcept { - return !data() ? nullptr : data() - offset(); + return !data() ? nullptr : data() - mapping_offset(); } const_pointer get_mapping_start() const noexcept { - return !data() ? nullptr : data() - offset(); + return !data() ? nullptr : data() - mapping_offset(); } /** diff --git a/include/mio/shared_mmap.hpp b/include/mio/shared_mmap.hpp index b914c18..f125a59 100644 --- a/include/mio/shared_mmap.hpp +++ b/include/mio/shared_mmap.hpp @@ -162,12 +162,6 @@ public: return pimpl_ ? pimpl_->mapped_length() : 0; } - /** - * Returns the offset, relative to the file's start, at which the mapping was - * requested to be created. - */ - size_type offset() const noexcept { return pimpl_ ? pimpl_->offset() : 0; } - /** * Returns a pointer to the first requested byte, or `nullptr` if no memory mapping * exists.