992934e00e
* feat: `ArrayBuffer:wrapData:withSize` init for iOS * Format * fix build error * Update ExampleFrameProcessorPlugin.m * docs: Add class docs for SharedArray
39 lines
756 B
C++
39 lines
756 B
C++
//
|
|
// MutableRawBuffer.cpp
|
|
// VisionCamera
|
|
//
|
|
// Created by Marc Rousavy on 17.01.24.
|
|
// Copyright © 2024 mrousavy. All rights reserved.
|
|
//
|
|
|
|
#include "MutableRawBuffer.h"
|
|
#include <functional>
|
|
#include <memory>
|
|
|
|
namespace vision {
|
|
|
|
MutableRawBuffer::MutableRawBuffer(uint8_t* data, size_t size, bool freeOnDealloc)
|
|
: _data(data), _size(size), _freeOnDealloc(freeOnDealloc) {}
|
|
|
|
MutableRawBuffer::MutableRawBuffer(size_t size) {
|
|
_size = size;
|
|
_data = (uint8_t*)malloc(size * sizeof(uint8_t));
|
|
_freeOnDealloc = true;
|
|
}
|
|
|
|
MutableRawBuffer::~MutableRawBuffer() {
|
|
if (_freeOnDealloc) {
|
|
free(_data);
|
|
}
|
|
}
|
|
|
|
size_t MutableRawBuffer::size() const {
|
|
return _size;
|
|
}
|
|
|
|
uint8_t* MutableRawBuffer::data() {
|
|
return _data;
|
|
}
|
|
|
|
} // namespace vision
|