mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-23 08:44:04 +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));
|
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)
|
|||||||
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)
|
|||||||
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)
|
|||||||
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.
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user