aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/ALc.c4
-rw-r--r--OpenAL32/Include/alMain.h3
-rw-r--r--OpenAL32/alAuxEffectSlot.c13
3 files changed, 10 insertions, 10 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index a3012650..14bdf98d 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -1779,7 +1779,7 @@ static ALCvoid FreeDevice(ALCdevice *device)
{
ALeffectState *state = device->DefaultSlot->EffectState;
device->DefaultSlot = NULL;
- ALeffectStateFactory_destroy(ALeffectState_getCreator(state), state);
+ DELETE(state);
}
if(device->BufferMap.size > 0)
@@ -2902,7 +2902,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName)
{
ALeffectState *state = device->DefaultSlot->EffectState;
device->DefaultSlot = NULL;
- ALeffectStateFactory_destroy(ALeffectState_getCreator(state), state);
+ DELETE(state);
ERR("Failed to initialize the default effect\n");
}
}
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index fc078175..c7ad6418 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -70,6 +70,9 @@ static const union {
#define SET_VTABLE1(T1, obj) ((obj)->vtbl = &(T1##_vtable))
#define SET_VTABLE2(T1, T2, obj) SET_VTABLE1(T1##_##T2, STATIC_CAST(T2, (obj)))
+#define NEW(T) (T##Factory_getFactory()->create())
+#define DELETE(obj) ((obj)->vtbl->getCreator()->vtbl->destroy((obj)))
+
#ifdef _WIN32
diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c
index 4003d440..42f6c103 100644
--- a/OpenAL32/alAuxEffectSlot.c
+++ b/OpenAL32/alAuxEffectSlot.c
@@ -74,8 +74,7 @@ AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslo
if(err != AL_NO_ERROR)
{
FreeThunkEntry(slot->id);
- ALeffectStateFactory_destroy(ALeffectState_getCreator(slot->EffectState),
- slot->EffectState);
+ DELETE(slot->EffectState);
al_free(slot);
alDeleteAuxiliaryEffectSlots(cur, effectslots);
@@ -124,8 +123,7 @@ AL_API ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, const ALuint *
FreeThunkEntry(slot->id);
RemoveEffectSlotArray(Context, slot);
- ALeffectStateFactory_destroy(ALeffectState_getCreator(slot->EffectState),
- slot->EffectState);
+ DELETE(slot->EffectState);
memset(slot, 0, sizeof(*slot));
al_free(slot);
@@ -598,7 +596,7 @@ ALenum InitializeEffect(ALCdevice *Device, ALeffectslot *EffectSlot, ALeffect *e
{
ALCdevice_Unlock(Device);
RestoreFPUMode(&oldMode);
- ALeffectStateFactory_destroy(ALeffectState_getCreator(State), State);
+ DELETE(State);
return AL_OUT_OF_MEMORY;
}
@@ -617,7 +615,7 @@ ALenum InitializeEffect(ALCdevice *Device, ALeffectslot *EffectSlot, ALeffect *e
RestoreFPUMode(&oldMode);
- ALeffectStateFactory_destroy(ALeffectState_getCreator(State), State);
+ DELETE(State);
State = NULL;
}
else
@@ -667,8 +665,7 @@ ALvoid ReleaseALAuxiliaryEffectSlots(ALCcontext *Context)
ALeffectslot *temp = Context->EffectSlotMap.array[pos].value;
Context->EffectSlotMap.array[pos].value = NULL;
- ALeffectStateFactory_destroy(ALeffectState_getCreator(temp->EffectState),
- temp->EffectState);
+ DELETE(temp->EffectState);
FreeThunkEntry(temp->id);
memset(temp, 0, sizeof(ALeffectslot));