Some CPool and CPools funcs, restoring original logic of pool lookup loops

This commit is contained in:
Sergeanur
2019-10-17 00:53:25 +03:00
parent 2c81844c20
commit 5b1ffb0912
13 changed files with 147 additions and 51 deletions

View File

@@ -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);