Skip to content

Commit

Permalink
fix: Add wrap ctor to MutableRawBuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
mrousavy committed Apr 21, 2024
1 parent 40c02ef commit 8227762
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
12 changes: 9 additions & 3 deletions package/android/src/main/cpp/MutableRawBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,17 @@ using namespace facebook;
class MutableRawBuffer : public jsi::MutableBuffer {

public:
explicit MutableRawBuffer(size_t size) {
explicit MutableRawBuffer(uint8_t* data, size_t size, bool freeOnDealloc) {
_size = size;
_data = new uint8_t[size];
_data = data;
_freeOnDealloc = freeOnDealloc;
}
explicit MutableRawBuffer(size_t size): MutableRawBuffer(new uint8_t[size], size, true) { }

~MutableRawBuffer() {
delete[] _data;
if (_freeOnDealloc) {
delete[] _data;
}
}

public:
Expand All @@ -37,6 +42,7 @@ class MutableRawBuffer : public jsi::MutableBuffer {
private:
uint8_t* _data;
size_t _size;
bool _freeOnDealloc;
};

} // namespace vision
12 changes: 9 additions & 3 deletions package/ios/FrameProcessors/MutableRawBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,17 @@ using namespace facebook;
class MutableRawBuffer : public jsi::MutableBuffer {

public:
explicit MutableRawBuffer(size_t size) {
explicit MutableRawBuffer(uint8_t* data, size_t size, bool freeOnDealloc) {
_size = size;
_data = new uint8_t[size];
_data = data;
_freeOnDealloc = freeOnDealloc;
}
explicit MutableRawBuffer(size_t size): MutableRawBuffer(new uint8_t[size], size, true) { }

~MutableRawBuffer() {
delete[] _data;
if (_freeOnDealloc) {
delete[] _data;
}
}

public:
Expand All @@ -37,6 +42,7 @@ class MutableRawBuffer : public jsi::MutableBuffer {
private:
uint8_t* _data;
size_t _size;
bool _freeOnDealloc;
};

} // namespace vision

0 comments on commit 8227762

Please sign in to comment.