diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-05-18 16:08:15 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-05-19 18:07:49 +0300 |
commit | 206fada99d8774fb7a9b4f1924f6caeccafdb9a1 (patch) | |
tree | ce4abd315ff3e6c6770476ade88382fdb50456cd /src/qcam/assets/feathericons/rotate-cw.svg | |
parent | a237dbeb7e2238beea7222bafe75f8a0d912c4af (diff) |
libcamera: file_descriptor: Implement move semantics for constructor
The FileDescriptor class, when constructed from a numerical file
descriptor, duplicates the file descriptor and takes ownership of the
copy. The caller has to close the original file descriptor manually if
needed. This is inefficient as the dup() and close() calls could be
avoided, but can also lead to resource leakage, as recently shown by
commit 353fc4c22322 ("libcamera: v4l2_videodevice: Fix dangling file
descriptor").
In an attempt to solve this problem, implement move semantics for the
FileDescriptor constructor. The constructor taking a numerical file
descriptor is split in two variants:
- A "fd copy" constructor that takes a const lvalue reference to a
numerical file descriptor and duplicates it (corresponding to the
current behaviour).
- A "fd move" constructor that takes a rvalue reference to a numerical
file descriptor and takes ownership of it.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Diffstat (limited to 'src/qcam/assets/feathericons/rotate-cw.svg')
0 files changed, 0 insertions, 0 deletions