Fix memory leaks in the advanced config example.

This commit is contained in:
David Reid
2018-03-04 10:22:27 +10:00
parent f0fff97fd9
commit 53692202a2
+8
View File
@@ -76,6 +76,7 @@ int main(int argc, char** argv)
mal_device_info* pPlaybackDeviceInfos = (mal_device_info*)malloc(playbackDeviceCount * sizeof(*pPlaybackDeviceInfos));
if (mal_enumerate_devices(&context, mal_device_type_playback, &playbackDeviceCount, pPlaybackDeviceInfos) != MAL_SUCCESS) {
printf("Failed to enumerate playback devices.");
free(pPlaybackDeviceInfos);
mal_context_uninit(&context);
return -4;
}
@@ -85,6 +86,9 @@ int main(int argc, char** argv)
printf(" %u: %s\n", iDevice, pPlaybackDeviceInfos[iDevice].name);
}
free(pPlaybackDeviceInfos);
pPlaybackDeviceInfos = NULL;
printf("\n");
// Enumerate capture devices.
@@ -98,6 +102,7 @@ int main(int argc, char** argv)
mal_device_info* pCaptureDeviceInfos = (mal_device_info*)malloc(captureDeviceCount * sizeof(*pCaptureDeviceInfos));
if (mal_enumerate_devices(&context, mal_device_type_capture, &captureDeviceCount, pCaptureDeviceInfos) != MAL_SUCCESS) {
printf("Failed to enumerate capture devices.");
free(pCaptureDeviceInfos);
mal_context_uninit(&context);
return -6;
}
@@ -107,6 +112,9 @@ int main(int argc, char** argv)
printf(" %u: %s\n", iDevice, pCaptureDeviceInfos[iDevice].name);
}
free(pCaptureDeviceInfos);
pCaptureDeviceInfos = NULL;
// Open the device.
//