diff options
author | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2011-08-29 16:10:08 -0400 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2011-08-29 16:10:08 -0400 |
commit | 85b8e62065b0255786cb0401a0b6f427668e0da6 (patch) | |
tree | e5320c55ef996159a7c55c47eb1b39ad9558d88e | |
parent | 07f884042eccd913c1e96c1503cc15dfe6af9d2b (diff) | |
download | opus-85b8e62065b0255786cb0401a0b6f427668e0da6.tar.gz |
Fixes minor issues from the previous allocation wrapper patch
-rw-r--r-- | libcelt/os_support.h | 3 | ||||
-rw-r--r-- | src/opus_decoder.c | 12 | ||||
-rw-r--r-- | src/opus_encoder.c | 12 | ||||
-rw-r--r-- | src/opus_multistream.c | 3 |
4 files changed, 14 insertions, 16 deletions
diff --git a/libcelt/os_support.h b/libcelt/os_support.h index bcc2a5d9..845e6504 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 8f9774c2..b1e990bb 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 ef1dbe54..30fe4939 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 6073c546..da498dd6 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; |