[libcamera-devel,v3,7/7] libcamera: MappedBuffer: Disable copy and assignment
diff mbox series

Message ID 20210212133056.873230-8-kieran.bingham@ideasonboard.com
State Accepted
Commit f9c0cf2a3a32ff9306da9931218909fa222e8295
Headers show
Series
  • Delete Copy-Move-Assign
Related show

Commit Message

Kieran Bingham Feb. 12, 2021, 1:30 p.m. UTC
MappedBuffers have a custom move constructor and assignment operator to
ensure that memory is not unmapped during object manipulation.

Because of the user-defined move constructor, the implicitly-declared
copy-constructor will already be deleted, however delete it explicitly
to help readability of the code, and make it clear that the object can
not be copied.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 include/libcamera/internal/buffer.h | 4 ++++
 1 file changed, 4 insertions(+)

Patch
diff mbox series

diff --git a/include/libcamera/internal/buffer.h b/include/libcamera/internal/buffer.h
index b7b0173f93f5..9da1fbd12c27 100644
--- a/include/libcamera/internal/buffer.h
+++ b/include/libcamera/internal/buffer.h
@@ -10,6 +10,7 @@ 
 #include <sys/mman.h>
 #include <vector>
 
+#include <libcamera/class.h>
 #include <libcamera/buffer.h>
 #include <libcamera/span.h>
 
@@ -34,6 +35,9 @@  protected:
 
 	int error_;
 	std::vector<Plane> maps_;
+
+private:
+	LIBCAMERA_DISABLE_COPY(MappedBuffer)
 };
 
 class MappedFrameBuffer : public MappedBuffer