diff --git a/libcelt/os_support.h b/libcelt/os_support.h index bcc2a5d991b523d2dc551dc74bcab7c2b81a9bc4..845e65041a1b1210df2ebd9c43d7ffcf012a3fd9 100644 --- a/libcelt/os_support.h +++ b/libcelt/os_support.h @@ -43,9 +43,6 @@ #ifndef OVERRIDE_CELT_ALLOC static inline void *opus_alloc (size_t size) { - /* WARNING: this is not equivalent to malloc(). If you want to use malloc() - or your own allocator, YOU NEED TO CLEAR THE MEMORY ALLOCATED. Otherwise - you will experience strange bugs */ return malloc(size); } #endif diff --git a/src/opus_decoder.c b/src/opus_decoder.c index 8f9774c23c729608dad7fc9b31fce33b3177bc3b..b1e990bb3dabcdfc6dde138cb81e851cdc27c374 100644 --- a/src/opus_decoder.c +++ b/src/opus_decoder.c @@ -132,20 +132,20 @@ failure: OpusDecoder *opus_decoder_create(int Fs, int channels, int *error) { int ret; - char *raw_state = (char*)opus_alloc(opus_decoder_get_size(channels)); - if (raw_state == NULL) + OpusDecoder *st = (OpusDecoder *)opus_alloc(opus_decoder_get_size(channels)); + if (st == NULL) { if (error) *error = OPUS_ALLOC_FAIL; return NULL; } - ret = opus_decoder_init((OpusDecoder*)raw_state, Fs, channels); + ret = opus_decoder_init(st, Fs, channels); if (ret != OPUS_OK) { - opus_free(raw_state); - raw_state = NULL; + opus_free(st); + st = NULL; } - return (OpusDecoder*)raw_state; + return st; } static void smooth_fade(const opus_val16 *in1, const opus_val16 *in2, opus_val16 *out, diff --git a/src/opus_encoder.c b/src/opus_encoder.c index ef1dbe544baf4f8447eab636179e82a8643b02bb..30fe49392770de301a766ad6b9b7ce02ac43668a 100644 --- a/src/opus_encoder.c +++ b/src/opus_encoder.c @@ -232,22 +232,22 @@ static unsigned char gen_toc(int mode, int framerate, int bandwidth, int channel OpusEncoder *opus_encoder_create(int Fs, int channels, int mode, int *error) { int ret; - char *raw_state = (char *)opus_alloc(opus_encoder_get_size(channels)); - if (raw_state == NULL) + OpusEncoder *st = (OpusEncoder *)opus_alloc(opus_encoder_get_size(channels)); + if (st == NULL) { if (error) *error = OPUS_ALLOC_FAIL; return NULL; } - ret = opus_encoder_init((OpusEncoder*)raw_state, Fs, channels, mode); + ret = opus_encoder_init(st, Fs, channels, mode); if (error) *error = ret; if (ret != OPUS_OK) { - opus_free(raw_state); - raw_state = NULL; + opus_free(st); + st = NULL; } - return (OpusEncoder*)raw_state; + return st; } #ifdef FIXED_POINT int opus_encode(OpusEncoder *st, const opus_val16 *pcm, int frame_size, diff --git a/src/opus_multistream.c b/src/opus_multistream.c index 6073c546c7eda3b77bd250a862542c145cf24c0d..da498dd6e0aa49a9a7d372c89808fcca3b0ea6db 100644 --- a/src/opus_multistream.c +++ b/src/opus_multistream.c @@ -33,11 +33,12 @@ #include "opus.h" #include "opus_private.h" #include "stack_alloc.h" -#include "stdio.h" +#include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdarg.h> #include "float_cast.h" +#include "os_support.h" typedef struct ChannelLayout { int nb_channels;