kodi
Mmap.h
1 /*
2  * Copyright (C) 2017-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include <cstddef>
12 
13 #include <sys/mman.h>
14 
15 namespace KODI
16 {
17 namespace UTILS
18 {
19 namespace POSIX
20 {
21 
25 class CMmap
26 {
27 public:
31  CMmap(void* addr, std::size_t length, int prot, int flags, int fildes, off_t offset);
32  ~CMmap();
33 
34  void* Data() const
35  {
36  return m_memory;
37  }
38  std::size_t Size() const
39  {
40  return m_size;
41  }
42 
43 private:
44  CMmap(CMmap const& other) = delete;
45  CMmap& operator=(CMmap const& other) = delete;
46 
47  std::size_t m_size;
48  void* m_memory;
49 };
50 
51 }
52 }
53 }
Definition: ColorUtils.h:18
CMmap(void *addr, std::size_t length, int prot, int flags, int fildes, off_t offset)
See mmap(3p) for parameter description.
Definition: Mmap.cpp:15
Definition: AudioDecoder.h:18
Wrapper for mapped memory that automatically calls munmap on destruction.
Definition: Mmap.h:25