From b0520d7a1bffaff1ca7161f5b7672f06b13808a1 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 16 Apr 2023 22:07:10 +0200 Subject: Use a shared_ptr for ArrayData rather than a shared_array. This is simpler and allows us to remove the hack of allocating some "maximum" buffer for incoming JPEG2000 data. It does mean that the buffer is zero-initialized before being written to, but hopefully that doesn't matter too much. --- src/array_data.h | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'src/array_data.h') diff --git a/src/array_data.h b/src/array_data.h index da7229bb..7a425f44 100644 --- a/src/array_data.h +++ b/src/array_data.h @@ -58,43 +58,33 @@ public: explicit ArrayData (int size); ArrayData (uint8_t const * data, int size); - /** Create an ArrayData by copying a shared_array<> - * @param data shared_array<> to copy (the shared_array<> is copied, not the data) - * @param size Size of data in bytes - */ - ArrayData (boost::shared_array data, int size); - /** Create an ArrayData by reading the contents of a file * @param file Filename to read */ - explicit ArrayData (boost::filesystem::path file); - - virtual ~ArrayData () {} + explicit ArrayData(boost::filesystem::path file); uint8_t const * data () const override { - return _data.get(); + return _data->data(); } uint8_t * data () override { - return _data.get(); + return _data->data(); } /** @return size of the data in _data, or whatever was last * passed to a set_size() call */ int size () const override { - return _size; + return _data->size(); } /** Set the size that will be returned from size() */ void set_size (int s) { - _size = s; + _data->resize(s); } private: - boost::shared_array _data; - /** amount of `valid' data in _data; the array may be larger */ - int _size = 0; + std::shared_ptr> _data; }; -- cgit v1.2.3