-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
88 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// MutableRawBuffer.cpp | ||
// react-native-filament | ||
// | ||
// Created by Marc Rousavy on 17.01.24. | ||
// Copyright © 2024 mrousavy. All rights reserved. | ||
// | ||
|
||
#include "MutableRawBuffer.h" | ||
#include <functional> | ||
#include <memory> | ||
|
||
namespace margelo { | ||
|
||
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 margelo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// MutableRawBuffer.h | ||
// react-native-filament | ||
// | ||
// Created by Marc Rousavy on 17.01.24. | ||
// Copyright © 2024 mrousavy. All rights reserved. | ||
// | ||
|
||
#pragma once | ||
|
||
#include <functional> | ||
#include <jsi/jsi.h> | ||
#include <memory> | ||
|
||
namespace margelo { | ||
|
||
using namespace facebook; | ||
|
||
class MutableRawBuffer : public jsi::MutableBuffer { | ||
|
||
public: | ||
explicit MutableRawBuffer(size_t size); | ||
explicit MutableRawBuffer(uint8_t* data, size_t size, bool freeOnDealloc); | ||
~MutableRawBuffer(); | ||
|
||
public: | ||
uint8_t* data() override; | ||
size_t size() const override; | ||
|
||
private: | ||
uint8_t* _data; | ||
size_t _size; | ||
bool _freeOnDealloc; | ||
}; | ||
|
||
} // namespace margelo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters