Use new/delete for context and effectslot properties

This commit is contained in:
Chris Robinson
2019-08-13 22:25:59 -07:00
parent ecab99bce9
commit 351ccf2e11
5 changed files with 10 additions and 6 deletions
+2 -2
View File
@@ -711,7 +711,7 @@ ALeffectslot::~ALeffectslot()
{
if(props->State) props->State->release();
TRACE("Freed unapplied AuxiliaryEffectSlot update %p\n", props);
al_free(props);
delete props;
}
if(Effect.State)
@@ -725,7 +725,7 @@ void UpdateEffectSlotProps(ALeffectslot *slot, ALCcontext *context)
/* Get an unused property container, or allocate a new one as needed. */
ALeffectslotProps *props{context->mFreeEffectslotProps.load(std::memory_order_relaxed)};
if(!props)
props = static_cast<ALeffectslotProps*>(al_calloc(16, sizeof(*props)));
props = new ALeffectslotProps{};
else
{
ALeffectslotProps *next;
+2
View File
@@ -32,6 +32,8 @@ struct ALeffectslotProps {
EffectState *State;
std::atomic<ALeffectslotProps*> next;
DEF_NEWDEL(ALeffectslotProps)
};
+1 -1
View File
@@ -827,7 +827,7 @@ void UpdateContextProps(ALCcontext *context)
/* Get an unused proprty container, or allocate a new one as needed. */
ALcontextProps *props{context->mFreeContextProps.load(std::memory_order_acquire)};
if(!props)
props = static_cast<ALcontextProps*>(al_calloc(16, sizeof(*props)));
props = new ALcontextProps{};
else
{
ALcontextProps *next;
+3 -3
View File
@@ -2322,14 +2322,14 @@ ALCcontext::~ALCcontext()
if(cprops)
{
TRACE("Freed unapplied context update %p\n", cprops);
al_free(cprops);
delete cprops;
}
size_t count{0};
cprops = mFreeContextProps.exchange(nullptr, std::memory_order_acquire);
while(cprops)
{
ALcontextProps *next{cprops->next.load(std::memory_order_relaxed)};
al_free(cprops);
delete cprops;
cprops = next;
++count;
}
@@ -2350,7 +2350,7 @@ ALCcontext::~ALCcontext()
{
ALeffectslotProps *next{eprops->next.load(std::memory_order_relaxed)};
if(eprops->State) eprops->State->release();
al_free(eprops);
delete eprops;
eprops = next;
++count;
}
+2
View File
@@ -50,6 +50,8 @@ struct ALcontextProps {
DistanceModel mDistanceModel;
std::atomic<ALcontextProps*> next;
DEF_NEWDEL(ALcontextProps)
};