mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 11:31:49 +00:00
update Bytearray to vector use
This commit is contained in:
parent
490727fdc0
commit
22328a9f64
2 changed files with 9 additions and 5 deletions
|
|
@ -8,7 +8,11 @@ using namespace lua;
|
|||
|
||||
|
||||
Bytearray::Bytearray(size_t capacity)
|
||||
: buffer(std::make_unique<ubyte[]>(capacity)), capacity(capacity) {
|
||||
: buffer(capacity) {
|
||||
buffer.resize(capacity);
|
||||
}
|
||||
|
||||
Bytearray::Bytearray(std::vector<ubyte> buffer) : buffer(std::move(buffer)) {
|
||||
}
|
||||
|
||||
Bytearray::~Bytearray() {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#include "lua_commons.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace lua {
|
||||
class Userdata {
|
||||
|
|
@ -14,10 +14,10 @@ namespace lua {
|
|||
};
|
||||
|
||||
class Bytearray : public Userdata {
|
||||
std::unique_ptr<ubyte[]> buffer;
|
||||
size_t capacity;
|
||||
std::vector<ubyte> buffer;
|
||||
public:
|
||||
Bytearray(size_t capacity);
|
||||
Bytearray(std::vector<ubyte> buffer);
|
||||
virtual ~Bytearray();
|
||||
|
||||
inline ubyte& operator[](size_t index) {
|
||||
|
|
@ -29,7 +29,7 @@ namespace lua {
|
|||
}
|
||||
|
||||
inline size_t size() const {
|
||||
return capacity;
|
||||
return buffer.size();
|
||||
}
|
||||
static int createMetatable(lua::State*);
|
||||
inline static std::string TYPENAME = "bytearray";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue