aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/effects
diff options
context:
space:
mode:
Diffstat (limited to 'Alc/effects')
-rw-r--r--Alc/effects/chorus.c8
-rw-r--r--Alc/effects/echo.c8
-rw-r--r--Alc/effects/flanger.c8
-rw-r--r--Alc/effects/reverb.c12
4 files changed, 19 insertions, 17 deletions
diff --git a/Alc/effects/chorus.c b/Alc/effects/chorus.c
index e1cbba2d..7877ff6f 100644
--- a/Alc/effects/chorus.c
+++ b/Alc/effects/chorus.c
@@ -57,7 +57,7 @@ typedef struct ALchorusState {
static ALvoid ALchorusState_Destruct(ALchorusState *state)
{
- free(state->SampleBuffer[0]);
+ al_free(state->SampleBuffer[0]);
state->SampleBuffer[0] = NULL;
state->SampleBuffer[1] = NULL;
ALeffectState_Destruct(STATIC_CAST(ALeffectState,state));
@@ -73,10 +73,10 @@ static ALboolean ALchorusState_deviceUpdate(ALchorusState *state, ALCdevice *Dev
if(maxlen != state->BufferLength)
{
- void *temp;
-
- temp = realloc(state->SampleBuffer[0], maxlen * sizeof(ALfloat) * 2);
+ void *temp = al_calloc(16, maxlen * sizeof(ALfloat) * 2);
if(!temp) return AL_FALSE;
+
+ al_free(state->SampleBuffer[0]);
state->SampleBuffer[0] = temp;
state->SampleBuffer[1] = state->SampleBuffer[0] + maxlen;
diff --git a/Alc/effects/echo.c b/Alc/effects/echo.c
index 0632a44d..163b6ecb 100644
--- a/Alc/effects/echo.c
+++ b/Alc/effects/echo.c
@@ -52,7 +52,7 @@ typedef struct ALechoState {
static ALvoid ALechoState_Destruct(ALechoState *state)
{
- free(state->SampleBuffer);
+ al_free(state->SampleBuffer);
state->SampleBuffer = NULL;
ALeffectState_Destruct(STATIC_CAST(ALeffectState,state));
}
@@ -69,10 +69,10 @@ static ALboolean ALechoState_deviceUpdate(ALechoState *state, ALCdevice *Device)
if(maxlen != state->BufferLength)
{
- void *temp;
-
- temp = realloc(state->SampleBuffer, maxlen * sizeof(ALfloat));
+ void *temp = al_calloc(16, maxlen * sizeof(ALfloat));
if(!temp) return AL_FALSE;
+
+ al_free(state->SampleBuffer);
state->SampleBuffer = temp;
state->BufferLength = maxlen;
}
diff --git a/Alc/effects/flanger.c b/Alc/effects/flanger.c
index 7b55977e..f18b2b0f 100644
--- a/Alc/effects/flanger.c
+++ b/Alc/effects/flanger.c
@@ -57,7 +57,7 @@ typedef struct ALflangerState {
static ALvoid ALflangerState_Destruct(ALflangerState *state)
{
- free(state->SampleBuffer[0]);
+ al_free(state->SampleBuffer[0]);
state->SampleBuffer[0] = NULL;
state->SampleBuffer[1] = NULL;
ALeffectState_Destruct(STATIC_CAST(ALeffectState,state));
@@ -73,10 +73,10 @@ static ALboolean ALflangerState_deviceUpdate(ALflangerState *state, ALCdevice *D
if(maxlen != state->BufferLength)
{
- void *temp;
-
- temp = realloc(state->SampleBuffer[0], maxlen * sizeof(ALfloat) * 2);
+ void *temp = al_calloc(16, maxlen * sizeof(ALfloat) * 2);
if(!temp) return AL_FALSE;
+
+ al_free(state->SampleBuffer[0]);
state->SampleBuffer[0] = temp;
state->SampleBuffer[1] = state->SampleBuffer[0] + maxlen;
diff --git a/Alc/effects/reverb.c b/Alc/effects/reverb.c
index 3f22b787..f8680d24 100644
--- a/Alc/effects/reverb.c
+++ b/Alc/effects/reverb.c
@@ -170,7 +170,7 @@ typedef struct ALreverbState {
static ALvoid ALreverbState_Destruct(ALreverbState *State)
{
- free(State->SampleBuffer);
+ al_free(State->SampleBuffer);
State->SampleBuffer = NULL;
ALeffectState_Destruct(STATIC_CAST(ALeffectState,State));
}
@@ -295,7 +295,6 @@ static ALboolean AllocLines(ALuint frequency, ALreverbState *State)
{
ALuint totalSamples, index;
ALfloat length;
- ALfloat *newBuffer = NULL;
// All delay line lengths are calculated to accomodate the full range of
// lengths given their respective paramters.
@@ -352,10 +351,13 @@ static ALboolean AllocLines(ALuint frequency, ALreverbState *State)
if(totalSamples != State->TotalSamples)
{
+ ALfloat *newBuffer;
+
TRACE("New reverb buffer length: %u samples (%f sec)\n", totalSamples, totalSamples/(float)frequency);
- newBuffer = realloc(State->SampleBuffer, sizeof(ALfloat) * totalSamples);
- if(newBuffer == NULL)
- return AL_FALSE;
+ newBuffer = al_calloc(16, sizeof(ALfloat) * totalSamples);
+ if(!newBuffer) return AL_FALSE;
+
+ al_free(State->SampleBuffer);
State->SampleBuffer = newBuffer;
State->TotalSamples = totalSamples;
}