aboutsummaryrefslogtreecommitdiffstats
path: root/al/auxeffectslot.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-12-26 22:37:12 -0800
committerChris Robinson <[email protected]>2023-12-26 22:37:12 -0800
commit205a73876234c0b1363189306530ada73ece56f2 (patch)
tree185ccb4d06ba136e4fee84324c6f1102c184734d /al/auxeffectslot.cpp
parent1fddc044ac765d00e64628e59edcbcd71f0046b1 (diff)
Try to start being a bit more pointer-owner conscious
Diffstat (limited to 'al/auxeffectslot.cpp')
-rw-r--r--al/auxeffectslot.cpp25
1 files changed, 10 insertions, 15 deletions
diff --git a/al/auxeffectslot.cpp b/al/auxeffectslot.cpp
index 408b742b..ea41a842 100644
--- a/al/auxeffectslot.cpp
+++ b/al/auxeffectslot.cpp
@@ -155,19 +155,17 @@ void AddActiveEffectSlots(const al::span<ALeffectslot*> auxslots, ALCcontext *co
*/
if(newcount < newarray->size()) UNLIKELY
{
- curarray = newarray;
+ std::unique_ptr<EffectSlotArray> oldarray{newarray};
newarray = EffectSlot::CreatePtrArray(newcount);
- std::copy_n(curarray->begin(), newcount, newarray->begin());
- delete curarray;
- curarray = nullptr;
+ std::copy_n(oldarray->begin(), newcount, newarray->begin());
}
std::uninitialized_fill_n(newarray->end(), newcount, nullptr);
- curarray = context->mActiveAuxSlots.exchange(newarray, std::memory_order_acq_rel);
+ std::unique_ptr<EffectSlotArray> oldarray{context->mActiveAuxSlots.exchange(newarray,
+ std::memory_order_acq_rel)};
std::ignore = context->mDevice->waitForMix();
- std::destroy_n(curarray->end(), curarray->size());
- delete curarray;
+ std::destroy_n(oldarray->end(), oldarray->size());
}
void RemoveActiveEffectSlots(const al::span<ALeffectslot*> auxslots, ALCcontext *context)
@@ -193,20 +191,17 @@ void RemoveActiveEffectSlots(const al::span<ALeffectslot*> auxslots, ALCcontext
auto newsize = static_cast<size_t>(std::distance(newarray->begin(), new_end));
if(newsize != newarray->size()) LIKELY
{
- curarray = newarray;
+ std::unique_ptr<EffectSlotArray> oldarray{newarray};
newarray = EffectSlot::CreatePtrArray(newsize);
- std::copy_n(curarray->begin(), newsize, newarray->begin());
-
- delete curarray;
- curarray = nullptr;
+ std::copy_n(oldarray->begin(), newsize, newarray->begin());
}
std::uninitialized_fill_n(newarray->end(), newsize, nullptr);
- curarray = context->mActiveAuxSlots.exchange(newarray, std::memory_order_acq_rel);
+ std::unique_ptr<EffectSlotArray> oldarray{context->mActiveAuxSlots.exchange(newarray,
+ std::memory_order_acq_rel)};
std::ignore = context->mDevice->waitForMix();
std::destroy_n(curarray->end(), curarray->size());
- delete curarray;
}
@@ -251,7 +246,7 @@ bool EnsureEffectSlots(ALCcontext *context, size_t needed)
context->mEffectSlotList.emplace_back();
auto sublist = context->mEffectSlotList.end() - 1;
sublist->FreeMask = ~0_u64;
- sublist->EffectSlots = static_cast<ALeffectslot*>(
+ sublist->EffectSlots = static_cast<gsl::owner<ALeffectslot*>>(
al_calloc(alignof(ALeffectslot), sizeof(ALeffectslot)*64));
if(!sublist->EffectSlots) UNLIKELY
{