start on GapBuffer class

This commit is contained in:
Josh Holtrop 2016-11-01 22:18:44 -04:00
parent fbca1f995a
commit 444653822e
2 changed files with 38 additions and 0 deletions

19
src/core/GapBuffer.cc Normal file
View File

@ -0,0 +1,19 @@
#include "GapBuffer.h"
#include "System.h"
GapBuffer::GapBuffer()
{
m_buffer = (uint8_t *)System::alloc_pages(1u);
m_size = System::page_size;
}
GapBuffer::GapBuffer(uint8_t * buffer, size_t size)
{
m_buffer = buffer;
m_size = size;
}
GapBuffer::~GapBuffer()
{
System::free_pages(m_buffer, m_size >> System::page_size_log);
}

19
src/core/GapBuffer.h Normal file
View File

@ -0,0 +1,19 @@
#ifndef GAPBUFFER_H
#define GAPBUFFER_H
#include <stdint.h>
#include <stdlib.h>
class GapBuffer
{
public:
GapBuffer();
GapBuffer(uint8_t * buffer, size_t size);
~GapBuffer();
protected:
uint8_t * m_buffer;
size_t m_size;
};
#endif