diff --git a/alloc/stack.cpp b/alloc/stack.cpp index fa74737e..b33a6d2d 100644 --- a/alloc/stack.cpp +++ b/alloc/stack.cpp @@ -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 (); +} diff --git a/alloc/stack.hpp b/alloc/stack.hpp index f0d78a0f..055a6bec 100644 --- a/alloc/stack.hpp +++ b/alloc/stack.hpp @@ -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; };