alloc/stack: add capacity/size/remain implementations

This commit is contained in:
Danny Robson 2015-11-24 16:49:11 +11:00
parent 8ea208daea
commit 5601c1e9c4
2 changed files with 28 additions and 0 deletions

View File

@ -99,3 +99,27 @@ stack::reset (void)
{
m_cursor = m_begin;
}
///////////////////////////////////////////////////////////////////////////////
size_t
stack::capacity (void) const
{
return m_end - m_begin;
}
//-----------------------------------------------------------------------------
size_t
stack::size (void) const
{
return m_cursor - m_begin;
}
//-----------------------------------------------------------------------------
size_t
stack::remain (void) const
{
return capacity () - size ();
}

View File

@ -39,6 +39,10 @@ namespace util { namespace alloc {
void reset (void);
size_t capacity (void) const;
size_t size (void) const;
size_t remain (void) const;
private:
char *m_begin, *m_end, *m_cursor;
};