/** SGX

The   sss    gggg x   x   
     s      g      x x    Engine
      sss   g  gg   x
         s  g   g  x x          Copyright 1995-2009.
     ssss    gggg x   x         Steven Goodwin. All Rights Reserved.
    
This version has been released under the GNU Public License v2.0.

Please see the license files for details.

File: sgx/src/sgx/core/memory/memframeblock.cpp

*/

#include "sgx/core/core.hpp"


CFrameBlock::CFrameBlock(void *ptr, tMEM_SIZE size, tUINT32 align)
{
	m_pFrameBlock = NULL;	// TODO
	SGX_UNUSED(ptr);
	SGX_UNUSED(align);

	m_pStartMemory = new tBYTE[size];
	m_pCurrent = m_pStartMemory;
	m_pEndMemory = m_pStartMemory+size;
}

CFrameBlock::~CFrameBlock()
{
	delete []m_pFrameBlock;
}

void *
CFrameBlock::Alloc(tMEM_SIZE size)
{
	if (size + m_pCurrent >= m_pEndMemory) {
		return NULL;
	}

	void *ptr = m_pCurrent;
	m_pCurrent += size;

	return ptr;
}

void
CFrameBlock::reset()
{
	m_pCurrent = m_pStartMemory;
}
