diff --git a/alloc/linear.cpp b/alloc/linear.cpp index 8e1fdc41..80ed26a4 100644 --- a/alloc/linear.cpp +++ b/alloc/linear.cpp @@ -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 (); +} diff --git a/alloc/linear.hpp b/alloc/linear.hpp index 141c536e..303789b4 100644 --- a/alloc/linear.hpp +++ b/alloc/linear.hpp @@ -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;