diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2019-05-21 22:16:23 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2019-05-23 11:54:39 +0300 |
commit | 1f32abb995a04b7c67af6d923fea82436e817de1 (patch) | |
tree | 257edb05de72a0c6eb5bfd2786a7612afc1cd908 /src/libcamera/camera.cpp | |
parent | 8d846ed8a7d9d7c9783472a618a7f369f0843e67 (diff) |
libcamera: camera: Simplify create() implementation
Now that the Camera class inherits from std::enable_shared_from_this, we
don't need to use std::allocate_shared anymore and can simplify the
Camera::create() implementation. This fixes compilation with recent
versions of libc++ whose std::allocate_shared implementation isn't
compatible with classes that are not publicly constructible.
The custom allocator is removed, but a custom deleter is needed as the
Camera destructor is private.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src/libcamera/camera.cpp')
-rw-r--r-- | src/libcamera/camera.cpp | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index 0f45ab7e..617ea99c 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -358,24 +358,17 @@ std::shared_ptr<Camera> Camera::create(PipelineHandler *pipe, const std::string &name, const std::set<Stream *> &streams) { - struct Allocator : std::allocator<Camera> { - void construct(void *p, PipelineHandler *pipe, - const std::string &name) + struct Deleter : std::default_delete<Camera> { + void operator()(Camera *camera) { - ::new(p) Camera(pipe, name); - } - void destroy(Camera *p) - { - p->~Camera(); + delete camera; } }; - std::shared_ptr<Camera> camera = - std::allocate_shared<Camera>(Allocator(), pipe, name); - + Camera *camera = new Camera(pipe, name); camera->streams_ = streams; - return camera; + return std::shared_ptr<Camera>(camera, Deleter()); } /** |