Commit 53692202 authored by David Reid's avatar David Reid

Fix memory leaks in the advanced config example.

parent f0fff97f
...@@ -76,6 +76,7 @@ int main(int argc, char** argv) ...@@ -76,6 +76,7 @@ int main(int argc, char** argv)
mal_device_info* pPlaybackDeviceInfos = (mal_device_info*)malloc(playbackDeviceCount * sizeof(*pPlaybackDeviceInfos)); mal_device_info* pPlaybackDeviceInfos = (mal_device_info*)malloc(playbackDeviceCount * sizeof(*pPlaybackDeviceInfos));
if (mal_enumerate_devices(&context, mal_device_type_playback, &playbackDeviceCount, pPlaybackDeviceInfos) != MAL_SUCCESS) { if (mal_enumerate_devices(&context, mal_device_type_playback, &playbackDeviceCount, pPlaybackDeviceInfos) != MAL_SUCCESS) {
printf("Failed to enumerate playback devices."); printf("Failed to enumerate playback devices.");
free(pPlaybackDeviceInfos);
mal_context_uninit(&context); mal_context_uninit(&context);
return -4; return -4;
} }
...@@ -85,6 +86,9 @@ int main(int argc, char** argv) ...@@ -85,6 +86,9 @@ int main(int argc, char** argv)
printf(" %u: %s\n", iDevice, pPlaybackDeviceInfos[iDevice].name); printf(" %u: %s\n", iDevice, pPlaybackDeviceInfos[iDevice].name);
} }
free(pPlaybackDeviceInfos);
pPlaybackDeviceInfos = NULL;
printf("\n"); printf("\n");
// Enumerate capture devices. // Enumerate capture devices.
...@@ -98,6 +102,7 @@ int main(int argc, char** argv) ...@@ -98,6 +102,7 @@ int main(int argc, char** argv)
mal_device_info* pCaptureDeviceInfos = (mal_device_info*)malloc(captureDeviceCount * sizeof(*pCaptureDeviceInfos)); mal_device_info* pCaptureDeviceInfos = (mal_device_info*)malloc(captureDeviceCount * sizeof(*pCaptureDeviceInfos));
if (mal_enumerate_devices(&context, mal_device_type_capture, &captureDeviceCount, pCaptureDeviceInfos) != MAL_SUCCESS) { if (mal_enumerate_devices(&context, mal_device_type_capture, &captureDeviceCount, pCaptureDeviceInfos) != MAL_SUCCESS) {
printf("Failed to enumerate capture devices."); printf("Failed to enumerate capture devices.");
free(pCaptureDeviceInfos);
mal_context_uninit(&context); mal_context_uninit(&context);
return -6; return -6;
} }
...@@ -107,6 +112,9 @@ int main(int argc, char** argv) ...@@ -107,6 +112,9 @@ int main(int argc, char** argv)
printf(" %u: %s\n", iDevice, pCaptureDeviceInfos[iDevice].name); printf(" %u: %s\n", iDevice, pCaptureDeviceInfos[iDevice].name);
} }
free(pCaptureDeviceInfos);
pCaptureDeviceInfos = NULL;
// Open the device. // Open the device.
// //
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment