diff options
| author | Carl Hetherington <cth@carlh.net> | 2020-10-31 23:10:39 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2020-11-02 00:12:56 +0100 |
| commit | 809fe8c8e6f28c87f48e6629560a2b52a148a8a7 (patch) | |
| tree | d2af064926ae732b7be3d82fb6fa4f4d412780e9 | |
| parent | 9e613ae8a3cd7994194d2d709f6ff9b88feac70b (diff) | |
Use some shared_ptr<> instead of raw pointers.
| -rw-r--r-- | src/frame.h | 9 | ||||
| -rw-r--r-- | src/mono_picture_frame.cc | 11 | ||||
| -rw-r--r-- | src/mono_picture_frame.h | 3 | ||||
| -rw-r--r-- | src/stereo_picture_frame.cc | 8 | ||||
| -rw-r--r-- | src/stereo_picture_frame.h | 3 |
5 files changed, 9 insertions, 25 deletions
diff --git a/src/frame.h b/src/frame.h index 6bd32104..69983c4a 100644 --- a/src/frame.h +++ b/src/frame.h @@ -49,18 +49,13 @@ public: Frame (R* reader, int n, boost::shared_ptr<const DecryptionContext> c) { /* XXX: unfortunate guesswork on this buffer size */ - _buffer = new B (Kumu::Megabyte); + _buffer.reset(new B(Kumu::Megabyte)); if (ASDCP_FAILURE (reader->ReadFrame (n, *_buffer, c->context(), c->hmac()))) { boost::throw_exception (ReadError ("could not read frame")); } } - ~Frame () - { - delete _buffer; - } - uint8_t const * data () const { return _buffer->RoData (); @@ -72,7 +67,7 @@ public: } private: - B* _buffer; + boost::shared_ptr<B> _buffer; }; } diff --git a/src/mono_picture_frame.cc b/src/mono_picture_frame.cc index d9a89fe1..7d24ea63 100644 --- a/src/mono_picture_frame.cc +++ b/src/mono_picture_frame.cc @@ -57,7 +57,7 @@ using namespace dcp; MonoPictureFrame::MonoPictureFrame (boost::filesystem::path path) { boost::uintmax_t const size = boost::filesystem::file_size (path); - _buffer = new ASDCP::JP2K::FrameBuffer (size); + _buffer.reset(new ASDCP::JP2K::FrameBuffer(size)); FILE* f = fopen_boost (path, "rb"); if (!f) { boost::throw_exception (FileError ("could not open JPEG2000 file", path, errno)); @@ -81,7 +81,7 @@ MonoPictureFrame::MonoPictureFrame (boost::filesystem::path path) MonoPictureFrame::MonoPictureFrame (ASDCP::JP2K::MXFReader* reader, int n, shared_ptr<DecryptionContext> c) { /* XXX: unfortunate guesswork on this buffer size */ - _buffer = new ASDCP::JP2K::FrameBuffer (4 * Kumu::Megabyte); + _buffer.reset(new ASDCP::JP2K::FrameBuffer(4 * Kumu::Megabyte)); ASDCP::Result_t const r = reader->ReadFrame (n, *_buffer, c->context(), c->hmac()); @@ -92,16 +92,11 @@ MonoPictureFrame::MonoPictureFrame (ASDCP::JP2K::MXFReader* reader, int n, share MonoPictureFrame::MonoPictureFrame (uint8_t const * data, int size) { - _buffer = new ASDCP::JP2K::FrameBuffer (size); + _buffer.reset(new ASDCP::JP2K::FrameBuffer(size)); _buffer->Size (size); memcpy (_buffer->Data(), data, size); } -/** MonoPictureFrame destructor */ -MonoPictureFrame::~MonoPictureFrame () -{ - delete _buffer; -} /** @return Pointer to JPEG2000 data */ uint8_t const * diff --git a/src/mono_picture_frame.h b/src/mono_picture_frame.h index 1b818144..caa279d2 100644 --- a/src/mono_picture_frame.h +++ b/src/mono_picture_frame.h @@ -67,7 +67,6 @@ class MonoPictureFrame : public boost::noncopyable public: explicit MonoPictureFrame (boost::filesystem::path path); MonoPictureFrame (uint8_t const * data, int size); - ~MonoPictureFrame (); boost::shared_ptr<OpenJPEGImage> xyz_image (int reduce = 0) const; @@ -83,7 +82,7 @@ private: MonoPictureFrame (ASDCP::JP2K::MXFReader* reader, int n, boost::shared_ptr<DecryptionContext>); - ASDCP::JP2K::FrameBuffer* _buffer; + boost::shared_ptr<ASDCP::JP2K::FrameBuffer> _buffer; }; } diff --git a/src/stereo_picture_frame.cc b/src/stereo_picture_frame.cc index 80165430..e8d7cd61 100644 --- a/src/stereo_picture_frame.cc +++ b/src/stereo_picture_frame.cc @@ -53,7 +53,7 @@ using namespace dcp; StereoPictureFrame::StereoPictureFrame (ASDCP::JP2K::MXFSReader* reader, int n, shared_ptr<DecryptionContext> c) { /* XXX: unfortunate guesswork on this buffer size */ - _buffer = new ASDCP::JP2K::SFrameBuffer (4 * Kumu::Megabyte); + _buffer.reset(new ASDCP::JP2K::SFrameBuffer(4 * Kumu::Megabyte)); if (ASDCP_FAILURE (reader->ReadFrame (n, *_buffer, c->context(), c->hmac()))) { boost::throw_exception (ReadError (String::compose ("could not read video frame %1 of %2", n))); @@ -62,13 +62,9 @@ StereoPictureFrame::StereoPictureFrame (ASDCP::JP2K::MXFSReader* reader, int n, StereoPictureFrame::StereoPictureFrame () { - _buffer = new ASDCP::JP2K::SFrameBuffer (4 * Kumu::Megabyte); + _buffer.reset(new ASDCP::JP2K::SFrameBuffer(4 * Kumu::Megabyte)); } -StereoPictureFrame::~StereoPictureFrame () -{ - delete _buffer; -} /** @param eye Eye to return (EYE_LEFT or EYE_RIGHT). * @param reduce a factor by which to reduce the resolution diff --git a/src/stereo_picture_frame.h b/src/stereo_picture_frame.h index a173b1c1..6dd6269b 100644 --- a/src/stereo_picture_frame.h +++ b/src/stereo_picture_frame.h @@ -59,7 +59,6 @@ class StereoPictureFrame : public boost::noncopyable { public: StereoPictureFrame (); - ~StereoPictureFrame (); boost::shared_ptr<OpenJPEGImage> xyz_image (Eye eye, int reduce = 0) const; @@ -79,7 +78,7 @@ private: StereoPictureFrame (ASDCP::JP2K::MXFSReader* reader, int n, boost::shared_ptr<DecryptionContext>); - ASDCP::JP2K::SFrameBuffer* _buffer; + boost::shared_ptr<ASDCP::JP2K::SFrameBuffer> _buffer; }; } |
