diff options
author | Sergeanur <s.anureev@yandex.ua> | 2019-10-16 23:53:25 +0200 |
---|---|---|
committer | Sergeanur <s.anureev@yandex.ua> | 2019-10-16 23:53:25 +0200 |
commit | 5b1ffb09124c7427b7efb421091179ddecc725c4 (patch) | |
tree | ac2d216a9aa6b79359371fe73b400c44fc5bca6e /src/core/templates.h | |
parent | Merge pull request #244 from Nick007J/master (diff) | |
download | re3-5b1ffb09124c7427b7efb421091179ddecc725c4.tar re3-5b1ffb09124c7427b7efb421091179ddecc725c4.tar.gz re3-5b1ffb09124c7427b7efb421091179ddecc725c4.tar.bz2 re3-5b1ffb09124c7427b7efb421091179ddecc725c4.tar.lz re3-5b1ffb09124c7427b7efb421091179ddecc725c4.tar.xz re3-5b1ffb09124c7427b7efb421091179ddecc725c4.tar.zst re3-5b1ffb09124c7427b7efb421091179ddecc725c4.zip |
Diffstat (limited to 'src/core/templates.h')
-rw-r--r-- | src/core/templates.h | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/core/templates.h b/src/core/templates.h index ef2db33a..f785d647 100644 --- a/src/core/templates.h +++ b/src/core/templates.h @@ -44,7 +44,20 @@ public: m_flags[i].free = 1; } } - int GetSize(void) { return m_size; } + ~CPool() { + Flush(); + } + void Flush() { + if (m_size > 0) { + free(m_entries); + free(m_flags); + m_entries = nil; + m_flags = nil; + m_size = 0; + m_allocPtr = 0; + } + } + int GetSize(void) const { return m_size; } T *New(void){ bool wrapped = false; do @@ -101,12 +114,14 @@ public: n++; return n; } + bool IsFreeSlot(int i) { return !!m_flags[i].free; } void ClearStorage(uint8 *&flags, U *&entries){ free(flags); free(entries); flags = nil; entries = nil; } + uint32 GetMaxEntrySize() const { return sizeof(U); } void CopyBack(uint8 *&flags, U *&entries){ memcpy(m_flags, flags, sizeof(uint8)*m_size); memcpy(m_entries, entries, sizeof(U)*m_size); |