MSVC: Workaround crtdbg macroing free().

This commit is contained in:
Hans-Kristian Arntzen 2021-09-30 14:12:08 +02:00
parent 9462b90067
commit 96d95fbb31
2 changed files with 10 additions and 10 deletions

View File

@ -1377,7 +1377,7 @@ public:
~Variant()
{
if (holder)
group->pools[type]->free_opaque(holder);
group->pools[type]->deallocate_opaque(holder);
}
// Marking custom move constructor as noexcept is important.
@ -1396,7 +1396,7 @@ public:
if (this != &other)
{
if (holder)
group->pools[type]->free_opaque(holder);
group->pools[type]->deallocate_opaque(holder);
holder = other.holder;
group = other.group;
type = other.type;
@ -1420,7 +1420,7 @@ public:
if (this != &other)
{
if (holder)
group->pools[type]->free_opaque(holder);
group->pools[type]->deallocate_opaque(holder);
if (other.holder)
holder = other.holder->clone(group->pools[other.type].get());
@ -1436,13 +1436,13 @@ public:
void set(IVariant *val, Types new_type)
{
if (holder)
group->pools[type]->free_opaque(holder);
group->pools[type]->deallocate_opaque(holder);
holder = nullptr;
if (!allow_type_rewrite && type != TypeNone && type != new_type)
{
if (val)
group->pools[new_type]->free_opaque(val);
group->pools[new_type]->deallocate_opaque(val);
SPIRV_CROSS_THROW("Overwriting a variant with new type.");
}
@ -1497,7 +1497,7 @@ public:
void reset()
{
if (holder)
group->pools[type]->free_opaque(holder);
group->pools[type]->deallocate_opaque(holder);
holder = nullptr;
type = TypeNone;
}

View File

@ -546,7 +546,7 @@ class ObjectPoolBase
{
public:
virtual ~ObjectPoolBase() = default;
virtual void free_opaque(void *ptr) = 0;
virtual void deallocate_opaque(void *ptr) = 0;
};
template <typename T>
@ -580,15 +580,15 @@ public:
return ptr;
}
void free(T *ptr)
void deallocate(T *ptr)
{
ptr->~T();
vacants.push_back(ptr);
}
void free_opaque(void *ptr) override
void deallocate_opaque(void *ptr) override
{
free(static_cast<T *>(ptr));
deallocate(static_cast<T *>(ptr));
}
void clear()