mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-21 15:56:58 +02:00
Fix memory leaks in the advanced config example.
This commit is contained in:
@@ -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.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user