1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 04:22:20 +02:00

Improved hotswapping with extension modules

This commit is contained in:
Brian Fiete 2024-12-29 11:02:17 -08:00
parent 769036584a
commit fd4fd43ce3
19 changed files with 836 additions and 232 deletions

View file

@ -30,7 +30,7 @@ struct MultiHashSetFuncs
}
};
template <typename T, typename TFuncs = AllocatorCLib<T> >
template <typename T, typename TFuncs = AllocatorCLib >
class MultiHashSet : public TFuncs
{
public:
@ -180,7 +180,7 @@ protected:
void ResizeEntries(int newSize)
{
BF_ASSERT(newSize >= mAllocSize);
Entry* newEntries = (Entry*)TFuncs::Allocate(sizeof(Entry) * newSize, alignof(Entry));
Entry* newEntries = TFuncs::allocate<Entry>(newSize);
for (int i = 0; i < mCount; i++)
{
@ -195,7 +195,7 @@ protected:
newEntries[i].mHashCode = -1;
}
TFuncs::Deallocate(mEntries);
TFuncs::deallocate(mEntries);
mEntries = newEntries;
mAllocSize = (int)newSize;
@ -276,7 +276,7 @@ public:
{
if (this->mHashHeads == NULL)
{
this->mHashHeads = (int*)TFuncs::Allocate(sizeof(int) * mHashSize, alignof(int));
this->mHashHeads = TFuncs::allocate<int>(mHashSize);
memset(this->mHashHeads, -1, sizeof(int) * mHashSize);
}
@ -298,7 +298,7 @@ public:
{
if (this->mHashHeads == NULL)
{
this->mHashHeads = (int*)TFuncs::Allocate(sizeof(int) * mHashSize, alignof(int));
this->mHashHeads = TFuncs::allocate<int>(mHashSize);
memset(this->mHashHeads, -1, sizeof(int) * mHashSize);
}
@ -332,7 +332,7 @@ public:
void Rehash(int newHashSize)
{
auto newHashHeads = (int*)TFuncs::Allocate(sizeof(int) * newHashSize, alignof(int));
auto newHashHeads = TFuncs::allocate<int>(newHashSize);
memset(newHashHeads, -1, sizeof(int) * newHashSize);
if (mHashHeads != NULL)
@ -364,7 +364,7 @@ public:
}
}
TFuncs::Deallocate(mHashHeads);
TFuncs::deallocate(mHashHeads);
}
mHashHeads = newHashHeads;
mHashSize = newHashSize;
@ -492,7 +492,7 @@ public:
void Clear()
{
if (!TFuncs::DeallocateAll())
if (!TFuncs::deallocateAll())
{
auto itr = begin();
auto endItr = end();
@ -502,8 +502,8 @@ public:
++itr;
FreeIdx(entry);
}
TFuncs::Deallocate(this->mHashHeads);
TFuncs::Deallocate(this->mEntries);
TFuncs::deallocate(this->mHashHeads);
TFuncs::deallocate(this->mEntries);
}
this->mHashSize = cDefaultHashSize;