diff options
author | Misael Lopez Cruz <misael.lopez@ti.com> | 2014-11-26 01:24:05 -0600 |
---|---|---|
committer | Misael Lopez Cruz <misael.lopez@ti.com> | 2014-11-26 03:06:17 -0600 |
commit | 989e6a8edfff8e7966b25428dd5fb1ed585f34be (patch) | |
tree | 4f70d9af5373f594fa9f56627125291ef94b2766 | |
parent | 722a512d3b92a94c46c856592ccc7015d2a6fd06 (diff) | |
download | jacinto6evm-989e6a8edfff8e7966b25428dd5fb1ed585f34be.tar.gz |
audio: Legacy: Zero-initialize allocated structs
Initialize to zeros the different structs used in the HAL.
The HAL uses non-NULL checks to free temporary audio buffers.
There were some aborts caused by freeing unallocated memory
because the audio buffer pointers were not zero-initialized.
Change-Id: I75ae704d5469e9e028bc7b67ef84b6a4047a7409
Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
-rw-r--r-- | audio/legacy/audio_hw.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/audio/legacy/audio_hw.c b/audio/legacy/audio_hw.c index fc81c03..8aa28ab 100644 --- a/audio/legacy/audio_hw.c +++ b/audio/legacy/audio_hw.c @@ -309,7 +309,7 @@ static int setup_stereo_to_mono_input_remix(struct j6_stream_in *in) { ALOGV("setup_stereo_to_mono_input_remix() stream=%p", in); - struct buffer_remix *br = (struct buffer_remix *)malloc(sizeof(struct buffer_remix)); + struct buffer_remix *br = (struct buffer_remix *)calloc(1, sizeof(struct buffer_remix)); if (!br) return -ENOMEM; @@ -349,7 +349,7 @@ static int setup_mono_input_remix(struct j6_voice_stream *stream) { ALOGV("setup_mono_input_remix() %s stream", stream->name); - struct buffer_remix *br = (struct buffer_remix *)malloc(sizeof(struct buffer_remix)); + struct buffer_remix *br = (struct buffer_remix *)calloc(1, sizeof(struct buffer_remix)); if (!br) return -ENOMEM; @@ -1261,7 +1261,7 @@ static int adev_open_output_stream(struct audio_hw_device *dev, struct j6_audio_device *adev = (struct j6_audio_device *)dev; struct j6_stream_out *out; - out = (struct j6_stream_out *)malloc(sizeof(struct j6_stream_out)); + out = (struct j6_stream_out *)calloc(1, sizeof(struct j6_stream_out)); if (!out) return -ENOMEM; @@ -1442,7 +1442,7 @@ static int adev_open_input_stream(struct audio_hw_device *dev, struct j6_stream_in *in; int ret; - in = (struct j6_stream_in *)malloc(sizeof(struct j6_stream_in)); + in = (struct j6_stream_in *)calloc(1, sizeof(struct j6_stream_in)); if (!in) return -ENOMEM; @@ -1582,7 +1582,7 @@ static int adev_open(const hw_module_t* module, const char* name, if (strcmp(name, AUDIO_HARDWARE_INTERFACE) != 0) return -EINVAL; - adev = (struct j6_audio_device*)malloc(sizeof(struct j6_audio_device)); + adev = (struct j6_audio_device*)calloc(1, sizeof(struct j6_audio_device)); if (!adev) return -ENOMEM; |