alloc/linear: add capacity/size/remain implementations

This commit is contained in:
Danny Robson 2015-11-24 16:48:46 +11:00
parent a8e4e39f8f
commit 8ea208daea
2 changed files with 25 additions and 0 deletions

View File

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

View File

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