pcm/Normalizer: use new/delete instead of malloc()/free()
This commit is contained in:
parent
7702643e1b
commit
d0dd035075
@ -4,9 +4,6 @@
|
|||||||
|
|
||||||
#include "Normalizer.hxx"
|
#include "Normalizer.hxx"
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
/*** Default configuration stuff ***/
|
/*** Default configuration stuff ***/
|
||||||
#define TARGET 16384 /*!< Target level (on a scale of 0-32767) */
|
#define TARGET 16384 /*!< Target level (on a scale of 0-32767) */
|
||||||
|
|
||||||
@ -34,10 +31,7 @@ struct Compressor {
|
|||||||
struct Compressor *
|
struct Compressor *
|
||||||
Compressor_new(unsigned int history) noexcept
|
Compressor_new(unsigned int history) noexcept
|
||||||
{
|
{
|
||||||
Compressor *obj = (Compressor *)malloc(sizeof(struct Compressor));
|
auto obj = new Compressor();
|
||||||
if (obj == nullptr)
|
|
||||||
/* out of memory, not much we can do */
|
|
||||||
abort();
|
|
||||||
|
|
||||||
obj->prefs.target = TARGET;
|
obj->prefs.target = TARGET;
|
||||||
obj->prefs.maxgain = GAINMAX;
|
obj->prefs.maxgain = GAINMAX;
|
||||||
@ -51,9 +45,9 @@ Compressor_new(unsigned int history) noexcept
|
|||||||
history = BUCKETS;
|
history = BUCKETS;
|
||||||
|
|
||||||
obj->bufsz = history;
|
obj->bufsz = history;
|
||||||
obj->peaks = (int *)calloc(history, sizeof(*obj->peaks));
|
obj->peaks = new int[history]{};
|
||||||
obj->gain = (int *)calloc(history, sizeof(*obj->gain));
|
obj->gain = new int[history]{};
|
||||||
obj->clipped = (int *)calloc(history, sizeof(*obj->clipped));
|
obj->clipped = new int[history]{};
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
@ -61,13 +55,10 @@ Compressor_new(unsigned int history) noexcept
|
|||||||
void
|
void
|
||||||
Compressor_delete(struct Compressor *obj) noexcept
|
Compressor_delete(struct Compressor *obj) noexcept
|
||||||
{
|
{
|
||||||
if (obj->peaks)
|
delete[] obj->peaks;
|
||||||
free(obj->peaks);
|
delete[] obj->gain;
|
||||||
if (obj->gain)
|
delete[] obj->clipped;
|
||||||
free(obj->gain);
|
delete obj;
|
||||||
if (obj->clipped)
|
|
||||||
free(obj->clipped);
|
|
||||||
free(obj);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CompressorConfig *
|
struct CompressorConfig *
|
||||||
|
Loading…
Reference in New Issue
Block a user