summaryrefslogtreecommitdiff
path: root/src/array_data.h
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2023-04-16 22:07:10 +0200
committerCarl Hetherington <cth@carlh.net>2023-04-16 22:14:26 +0200
commitb0520d7a1bffaff1ca7161f5b7672f06b13808a1 (patch)
tree8b7777c6fc7fc6f2f36e85c60151031b8860a09b /src/array_data.h
parent65d21ed2de3a76dc574c8ad111fc02d8f696fcd6 (diff)
Use a shared_ptr<vector> 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.
Diffstat (limited to 'src/array_data.h')
-rw-r--r--src/array_data.h22
1 files changed, 6 insertions, 16 deletions
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<uint8_t> 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<uint8_t> _data;
- /** amount of `valid' data in _data; the array may be larger */
- int _size = 0;
+ std::shared_ptr<std::vector<uint8_t>> _data;
};