diff options
-rw-r--r-- | Alc/effects/autowah.c | 7 | ||||
-rw-r--r-- | Alc/effects/chorus.c | 7 | ||||
-rw-r--r-- | Alc/effects/compressor.c | 7 | ||||
-rw-r--r-- | Alc/effects/dedicated.c | 7 | ||||
-rw-r--r-- | Alc/effects/distortion.c | 7 | ||||
-rw-r--r-- | Alc/effects/echo.c | 7 | ||||
-rw-r--r-- | Alc/effects/equalizer.c | 7 | ||||
-rw-r--r-- | Alc/effects/flanger.c | 7 | ||||
-rw-r--r-- | Alc/effects/modulator.c | 7 | ||||
-rw-r--r-- | Alc/effects/null.c | 18 | ||||
-rw-r--r-- | Alc/effects/reverb.c | 7 | ||||
-rw-r--r-- | OpenAL32/Include/alAuxEffectSlot.h | 5 | ||||
-rw-r--r-- | OpenAL32/Include/alMain.h | 3 |
13 files changed, 40 insertions, 56 deletions
diff --git a/Alc/effects/autowah.c b/Alc/effects/autowah.c index 527e3be6..9857c722 100644 --- a/Alc/effects/autowah.c +++ b/Alc/effects/autowah.c @@ -151,10 +151,7 @@ static ALvoid ALautowahState_process(ALautowahState *state, ALuint SamplesToDo, } } -static void ALautowahState_Delete(ALautowahState *state) -{ - free(state); -} +DECLARE_DEFAULT_ALLOCATORS(ALautowahState) DEFINE_ALEFFECTSTATE_VTABLE(ALautowahState); @@ -167,7 +164,7 @@ static ALeffectState *ALautowahStateFactory_create(ALautowahStateFactory *UNUSED { ALautowahState *state; - state = malloc(sizeof(*state)); + state = ALautowahState_New(sizeof(*state)); if(!state) return NULL; SET_VTABLE2(ALautowahState, ALeffectState, state); diff --git a/Alc/effects/chorus.c b/Alc/effects/chorus.c index 4945faf2..f2e43eb6 100644 --- a/Alc/effects/chorus.c +++ b/Alc/effects/chorus.c @@ -224,10 +224,7 @@ static ALvoid ALchorusState_process(ALchorusState *state, ALuint SamplesToDo, co } } -static void ALchorusState_Delete(ALchorusState *state) -{ - free(state); -} +DECLARE_DEFAULT_ALLOCATORS(ALchorusState) DEFINE_ALEFFECTSTATE_VTABLE(ALchorusState); @@ -240,7 +237,7 @@ static ALeffectState *ALchorusStateFactory_create(ALchorusStateFactory *UNUSED(f { ALchorusState *state; - state = malloc(sizeof(*state)); + state = ALchorusState_New(sizeof(*state)); if(!state) return NULL; SET_VTABLE2(ALchorusState, ALeffectState, state); diff --git a/Alc/effects/compressor.c b/Alc/effects/compressor.c index bab155c8..9728cabe 100644 --- a/Alc/effects/compressor.c +++ b/Alc/effects/compressor.c @@ -133,10 +133,7 @@ static ALvoid ALcompressorState_process(ALcompressorState *state, ALuint Samples } } -static void ALcompressorState_Delete(ALcompressorState *state) -{ - free(state); -} +DECLARE_DEFAULT_ALLOCATORS(ALcompressorState) DEFINE_ALEFFECTSTATE_VTABLE(ALcompressorState); @@ -149,7 +146,7 @@ static ALeffectState *ALcompressorStateFactory_create(ALcompressorStateFactory * { ALcompressorState *state; - state = malloc(sizeof(*state)); + state = ALcompressorState_New(sizeof(*state)); if(!state) return NULL; SET_VTABLE2(ALcompressorState, ALeffectState, state); diff --git a/Alc/effects/dedicated.c b/Alc/effects/dedicated.c index fe57c7d8..89af1c84 100644 --- a/Alc/effects/dedicated.c +++ b/Alc/effects/dedicated.c @@ -76,10 +76,7 @@ static ALvoid ALdedicatedState_process(ALdedicatedState *state, ALuint SamplesTo } } -static void ALdedicatedState_Delete(ALdedicatedState *state) -{ - free(state); -} +DECLARE_DEFAULT_ALLOCATORS(ALdedicatedState) DEFINE_ALEFFECTSTATE_VTABLE(ALdedicatedState); @@ -93,7 +90,7 @@ ALeffectState *ALdedicatedStateFactory_create(ALdedicatedStateFactory *UNUSED(fa ALdedicatedState *state; ALsizei s; - state = malloc(sizeof(*state)); + state = ALdedicatedState_New(sizeof(*state)); if(!state) return NULL; SET_VTABLE2(ALdedicatedState, ALeffectState, state); diff --git a/Alc/effects/distortion.c b/Alc/effects/distortion.c index e39a8197..b535655b 100644 --- a/Alc/effects/distortion.c +++ b/Alc/effects/distortion.c @@ -170,10 +170,7 @@ static ALvoid ALdistortionState_process(ALdistortionState *state, ALuint Samples } } -static void ALdistortionState_Delete(ALdistortionState *state) -{ - free(state); -} +DECLARE_DEFAULT_ALLOCATORS(ALdistortionState) DEFINE_ALEFFECTSTATE_VTABLE(ALdistortionState); @@ -186,7 +183,7 @@ static ALeffectState *ALdistortionStateFactory_create(ALdistortionStateFactory * { ALdistortionState *state; - state = malloc(sizeof(*state)); + state = ALdistortionState_New(sizeof(*state)); if(!state) return NULL; SET_VTABLE2(ALdistortionState, ALeffectState, state); diff --git a/Alc/effects/echo.c b/Alc/effects/echo.c index 7471c3dd..9513a611 100644 --- a/Alc/effects/echo.c +++ b/Alc/effects/echo.c @@ -161,10 +161,7 @@ static ALvoid ALechoState_process(ALechoState *state, ALuint SamplesToDo, const state->Offset = offset; } -static void ALechoState_Delete(ALechoState *state) -{ - free(state); -} +DECLARE_DEFAULT_ALLOCATORS(ALechoState) DEFINE_ALEFFECTSTATE_VTABLE(ALechoState); @@ -177,7 +174,7 @@ ALeffectState *ALechoStateFactory_create(ALechoStateFactory *UNUSED(factory)) { ALechoState *state; - state = malloc(sizeof(*state)); + state = ALechoState_New(sizeof(*state)); if(!state) return NULL; SET_VTABLE2(ALechoState, ALeffectState, state); diff --git a/Alc/effects/equalizer.c b/Alc/effects/equalizer.c index d5bd2caf..cfe7c46c 100644 --- a/Alc/effects/equalizer.c +++ b/Alc/effects/equalizer.c @@ -155,10 +155,7 @@ static ALvoid ALequalizerState_process(ALequalizerState *state, ALuint SamplesTo } } -static void ALequalizerState_Delete(ALequalizerState *state) -{ - free(state); -} +DECLARE_DEFAULT_ALLOCATORS(ALequalizerState) DEFINE_ALEFFECTSTATE_VTABLE(ALequalizerState); @@ -172,7 +169,7 @@ ALeffectState *ALequalizerStateFactory_create(ALequalizerStateFactory *UNUSED(fa ALequalizerState *state; int it; - state = malloc(sizeof(*state)); + state = ALequalizerState_New(sizeof(*state)); if(!state) return NULL; SET_VTABLE2(ALequalizerState, ALeffectState, state); diff --git a/Alc/effects/flanger.c b/Alc/effects/flanger.c index a94cd365..b8560206 100644 --- a/Alc/effects/flanger.c +++ b/Alc/effects/flanger.c @@ -224,10 +224,7 @@ static ALvoid ALflangerState_process(ALflangerState *state, ALuint SamplesToDo, } } -static void ALflangerState_Delete(ALflangerState *state) -{ - free(state); -} +DECLARE_DEFAULT_ALLOCATORS(ALflangerState) DEFINE_ALEFFECTSTATE_VTABLE(ALflangerState); @@ -240,7 +237,7 @@ ALeffectState *ALflangerStateFactory_create(ALflangerStateFactory *UNUSED(factor { ALflangerState *state; - state = malloc(sizeof(*state)); + state = ALflangerState_New(sizeof(*state)); if(!state) return NULL; SET_VTABLE2(ALflangerState, ALeffectState, state); diff --git a/Alc/effects/modulator.c b/Alc/effects/modulator.c index 17ca7e17..a5475708 100644 --- a/Alc/effects/modulator.c +++ b/Alc/effects/modulator.c @@ -171,10 +171,7 @@ static ALvoid ALmodulatorState_process(ALmodulatorState *state, ALuint SamplesTo } } -static void ALmodulatorState_Delete(ALmodulatorState *state) -{ - free(state); -} +DECLARE_DEFAULT_ALLOCATORS(ALmodulatorState) DEFINE_ALEFFECTSTATE_VTABLE(ALmodulatorState); @@ -187,7 +184,7 @@ static ALeffectState *ALmodulatorStateFactory_create(ALmodulatorStateFactory *UN { ALmodulatorState *state; - state = malloc(sizeof(*state)); + state = ALmodulatorState_New(sizeof(*state)); if(!state) return NULL; SET_VTABLE2(ALmodulatorState, ALeffectState, state); diff --git a/Alc/effects/null.c b/Alc/effects/null.c index 816a2525..6dacd021 100644 --- a/Alc/effects/null.c +++ b/Alc/effects/null.c @@ -48,10 +48,20 @@ static ALvoid ALnullState_process(ALnullState* UNUSED(state), ALuint UNUSED(samp (void)samplesOut; } -/* This frees the memory used by the object, after it has been destructed. */ -static void ALnullState_Delete(ALnullState *state) +/* This allocates memory to store the object, before it gets constructed. + * DECLARE_DEFAULT_ALLOCATORS can be used to declate a default method. + */ +static void *ALnullState_New(size_t size) +{ + return malloc(size); +} + +/* This frees the memory used by the object, after it has been destructed. + * DECLARE_DEFAULT_ALLOCATORS can be used to declate a default method. + */ +static void ALnullState_Delete(void *ptr) { - free(state); + free(ptr); } /* Define the forwards and the ALeffectState vtable for this type. */ @@ -67,7 +77,7 @@ ALeffectState *ALnullStateFactory_create(ALnullStateFactory *UNUSED(factory)) { ALnullState *state; - state = calloc(1, sizeof(*state)); + state = ALnullState_New(sizeof(*state)); if(!state) return NULL; /* Set vtables for inherited types. */ SET_VTABLE2(ALnullState, ALeffectState, state); diff --git a/Alc/effects/reverb.c b/Alc/effects/reverb.c index 75ec76e3..d5a28823 100644 --- a/Alc/effects/reverb.c +++ b/Alc/effects/reverb.c @@ -1170,10 +1170,7 @@ static ALvoid ALreverbState_Destruct(ALreverbState *State) State->SampleBuffer = NULL; } -static void ALreverbState_Delete(ALreverbState *state) -{ - free(state); -} +DECLARE_DEFAULT_ALLOCATORS(ALreverbState) DEFINE_ALEFFECTSTATE_VTABLE(ALreverbState); @@ -1187,7 +1184,7 @@ static ALeffectState *ALreverbStateFactory_create(ALreverbStateFactory* UNUSED(f ALreverbState *state; ALuint index; - state = malloc(sizeof(ALreverbState)); + state = ALreverbState_New(sizeof(*state)); if(!state) return NULL; SET_VTABLE2(ALreverbState, ALeffectState, state); diff --git a/OpenAL32/Include/alAuxEffectSlot.h b/OpenAL32/Include/alAuxEffectSlot.h index c7182d9b..81210776 100644 --- a/OpenAL32/Include/alAuxEffectSlot.h +++ b/OpenAL32/Include/alAuxEffectSlot.h @@ -22,7 +22,7 @@ struct ALeffectStateVtable { void (*const update)(ALeffectState *state, ALCdevice *device, const struct ALeffectslot *slot); void (*const process)(ALeffectState *state, ALuint samplesToDo, const ALfloat *restrict samplesIn, ALfloat (*restrict samplesOut)[BUFFERSIZE]); - void (*const Delete)(struct ALeffectState *state); + void (*const Delete)(void *ptr); }; #define DEFINE_ALEFFECTSTATE_VTABLE(T) \ @@ -30,7 +30,8 @@ DECLARE_THUNK(T, ALeffectState, void, Destruct) \ DECLARE_THUNK1(T, ALeffectState, ALboolean, deviceUpdate, ALCdevice*) \ DECLARE_THUNK2(T, ALeffectState, void, update, ALCdevice*, const ALeffectslot*) \ DECLARE_THUNK3(T, ALeffectState, void, process, ALuint, const ALfloat*restrict, ALfloatBUFFERSIZE*restrict) \ -DECLARE_THUNK(T, ALeffectState, void, Delete) \ +static void T##_ALeffectState_Delete(void *ptr) \ +{ return T##_Delete(STATIC_UPCAST(T, ALeffectState, ptr)); } \ \ static const struct ALeffectStateVtable T##_ALeffectState_vtable = { \ T##_ALeffectState_Destruct, \ diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index 0f4a3c7e..519b825e 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -376,6 +376,9 @@ static rettype T1##_##T2##_##func(T2 *obj, argtype1 a, argtype2 b) \ static rettype T1##_##T2##_##func(T2 *obj, argtype1 a, argtype2 b, argtype3 c) \ { return T1##_##func(STATIC_UPCAST(T1, T2, obj), a, b, c); } +#define DECLARE_DEFAULT_ALLOCATORS(T) \ +static void* T##_New(size_t size) { return malloc(size); } \ +static void T##_Delete(void *ptr) { free(ptr); } /* Helper to extract an argument list for VCALL. Not used directly. */ #define EXTRACT_VCALL_ARGS(...) __VA_ARGS__)) |