src/io/utils_apple_audio.c: use AUBIO_ARRAY / AUBIO_FREE
authorPaul Brossier <piem@piem.org>
Sat, 23 Mar 2013 00:09:53 +0000 (19:09 -0500)
committerPaul Brossier <piem@piem.org>
Sat, 23 Mar 2013 00:09:53 +0000 (19:09 -0500)
src/io/utils_apple_audio.c

index dbd1fbd90136a1dba2ad85e6742c900c150ae8cc..31538edd0f3541d4be6c8b2ff7d66d919891d4c1 100644 (file)
@@ -4,6 +4,7 @@
 #include <CoreFoundation/CoreFoundation.h>
 // ExtAudioFileRef, AudioStreamBasicDescription, AudioBufferList, ...
 #include <AudioToolbox/AudioToolbox.h>
+#include "aubio_priv.h"
 
 int createAubioBufferList(AudioBufferList *bufferList, int channels, int segmentSize);
 void freeAudioBufferList(AudioBufferList *bufferList);
@@ -12,7 +13,7 @@ CFURLRef getURLFromPath(const char * path);
 int createAubioBufferList(AudioBufferList * bufferList, int channels, int segmentSize) {
   bufferList->mNumberBuffers = 1;
   bufferList->mBuffers[0].mNumberChannels = channels;
-  bufferList->mBuffers[0].mData = (short *)malloc(segmentSize * sizeof(short));
+  bufferList->mBuffers[0].mData = AUBIO_ARRAY(short, segmentSize);
   bufferList->mBuffers[0].mDataByteSize = segmentSize * sizeof(short);
   return 0;
 }
@@ -22,7 +23,7 @@ void freeAudioBufferList(AudioBufferList *bufferList) {
   if (!bufferList) return;
   for (i = 0; i < bufferList->mNumberBuffers; i++) {
     if (bufferList->mBuffers[i].mData) {
-      free (bufferList->mBuffers[i].mData);
+      AUBIO_FREE(bufferList->mBuffers[i].mData);
       bufferList->mBuffers[i].mData = NULL;
     }
   }