19 unsigned char* mem = (
unsigned char*)malloc(size);
20 m_memory.push_back(mem);
28 for(
size_t i = 0; i < m_memory.size(); ++i)
34 void*
alloc(
size_t required,
long& offset)
36 required = (
sizeof(T) * required);
37 for(
size_t i = 0; i < m_memory.size(); ++i)
39 size_t used = m_used[i];
40 if((m_capacity - used) >= required)
42 m_used[i] += required;
44 return m_memory[i] + used;
49 ssize_t size = (required >
m_capacity) ? required : m_capacity;
51 unsigned char* mem = (
unsigned char*)malloc(size);
53 m_memory.push_back(mem);
54 m_used.push_back(required);
67 m_memory = (
unsigned char*)malloc(m_size);
78 void*
alloc(
size_t required,
long& offset)
80 required = (
sizeof(T) * required);
82 if((m_capacity - m_used) < required)
84 long addSize = (required > m_size) ? required : m_size;
85 m_capacity += addSize;
87 unsigned char* tmp = (
unsigned char*)realloc(m_memory, m_capacity);
97 if(m_memory != m_address)
99 offset = m_memory - m_address;
104 unsigned char* ptr = &m_memory[
m_used];
105 memset(ptr, 0, required);
112 m_memory = (
unsigned char*)realloc(m_memory, m_used);
113 if(m_memory != m_address)
115 std::cout <<
"FUCK WHY" << std::endl;
void * alloc(size_t required, long &offset)
virtual ~ChunkMemoryHandler()
BlockMemoryHandler(size_t size=32)
unsigned char * m_address
std::vector< unsigned char * > m_memory
virtual ~BlockMemoryHandler()
std::vector< size_t > m_used
void * alloc(size_t required, long &offset)
ChunkMemoryHandler(size_t size=131072)