MCPcopy Create free account
hub / github.com/Exiv2/exiv2 / munmap

Method munmap

src/basicio.cpp:190–223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

188}
189
190int FileIo::munmap() {
191 int rc = 0;
192 if (p_->pMappedArea_) {
193#if defined _WIN32
194 UnmapViewOfFile(p_->pMappedArea_);
195 CloseHandle(p_->hMap_);
196 p_->hMap_ = nullptr;
197 CloseHandle(p_->hFile_);
198 p_->hFile_ = nullptr;
199#elif __has_include(<sys/mman.h>)
200 if (::munmap(p_->pMappedArea_, p_->mappedLength_) != 0) {
201 rc = 1;
202 }
203#else
204#error Platforms without mmap are not supported. See https://github.com/Exiv2/exiv2/issues/2380
205 if (p_->isWriteable_) {
206 seek(0, BasicIo::beg);
207 write(p_->pMappedArea_, p_->mappedLength_);
208 }
209 if (p_->isMalloced_) {
210 delete[] p_->pMappedArea_;
211 p_->isMalloced_ = false;
212 }
213#endif
214 }
215 if (p_->isWriteable_) {
216 if (p_->fp_)
217 p_->switchMode(Impl::opRead);
218 p_->isWriteable_ = false;
219 }
220 p_->pMappedArea_ = nullptr;
221 p_->mappedLength_ = 0;
222 return rc;
223}
224
225byte* FileIo::mmap(bool isWriteable) {
226 if (munmap() != 0) {

Callers

nothing calls this directly

Calls 2

switchModeMethod · 0.80
writeFunction · 0.50

Tested by

no test coverage detected