diff options
author | Chris Robinson <[email protected]> | 2018-03-23 11:39:07 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-03-23 11:39:07 -0700 |
commit | 63c9d95b845c0554b59eb7edf6bb05e5650633ba (patch) | |
tree | b19fd85ead44fb9b0942b30fbc0c7caced415370 | |
parent | 63c35248bed5d3718c492e78933a1c5f8d187a16 (diff) |
Combine multiple allocations into one
-rw-r--r-- | Alc/backends/coreaudio.c | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/Alc/backends/coreaudio.c b/Alc/backends/coreaudio.c index b2545c47..d6d32cc8 100644 --- a/Alc/backends/coreaudio.c +++ b/Alc/backends/coreaudio.c @@ -53,36 +53,25 @@ typedef struct { static const ALCchar ca_device[] = "CoreAudio Default"; -static AudioBufferList* allocate_buffer_list(UInt32 channelCount, UInt32 byteSize) +static AudioBufferList *allocate_buffer_list(UInt32 channelCount, UInt32 byteSize) { AudioBufferList *list; - list = calloc(1, sizeof(AudioBufferList) + sizeof(AudioBuffer)); + list = calloc(1, FAM_SIZE(AudioBufferList, mBuffers, 1) + byteSize); if(list) { list->mNumberBuffers = 1; list->mBuffers[0].mNumberChannels = channelCount; list->mBuffers[0].mDataByteSize = byteSize; - list->mBuffers[0].mData = malloc(byteSize); - if(list->mBuffers[0].mData == NULL) - { - free(list); - list = NULL; - } + list->mBuffers[0].mData = &list->mBuffers[1]; } return list; } -static void destroy_buffer_list(AudioBufferList* list) +static void destroy_buffer_list(AudioBufferList *list) { - if(list) - { - UInt32 i; - for(i = 0;i < list->mNumberBuffers;i++) - free(list->mBuffers[i].mData); - free(list); - } + free(list); } |