mirror of
https://github.com/jakcron/nstool.git
synced 2024-12-23 03:05:27 +00:00
38 lines
861 B
C++
38 lines
861 B
C++
#pragma once
|
|
#include <cstring>
|
|
#include <cstdio>
|
|
#include <cstdlib>
|
|
#include <ctime>
|
|
#include <vector>
|
|
#include <fnd/types.h>
|
|
|
|
namespace fnd
|
|
{
|
|
class MemoryBlob
|
|
{
|
|
public:
|
|
MemoryBlob();
|
|
MemoryBlob(const byte_t* bytes, size_t len);
|
|
|
|
void alloc(size_t size);
|
|
void extend(size_t new_size);
|
|
|
|
inline byte_t& operator[](size_t index) { return mData[index]; }
|
|
inline const byte_t& operator[](size_t index) const { return mData[index]; }
|
|
|
|
inline byte_t* getBytes() { return mData.data(); }
|
|
inline const byte_t* getBytes() const { return mData.data(); }
|
|
inline size_t getSize() const { return mVisableSize; }
|
|
private:
|
|
const std::string kModuleName = "MEMORY_BLOB";
|
|
static const size_t kAllocBlockSize = 0x1000;
|
|
|
|
std::vector<byte_t> mData;
|
|
size_t mSize;
|
|
size_t mVisableSize;
|
|
|
|
void allocateMemory(size_t size);
|
|
void clearMemory();
|
|
};
|
|
}
|