soundio_disconnect: allow NULL parameter

This commit is contained in:
Andrew Kelley 2015-09-11 19:08:16 -07:00
parent 0887b1ee3d
commit 4a0b3579d4
2 changed files with 5 additions and 2 deletions

View file

@ -154,8 +154,6 @@ const char *soundio_backend_name(enum SoundIoBackend backend) {
void soundio_destroy(struct SoundIo *soundio) {
SoundIoPrivate *si = (SoundIoPrivate *)soundio;
if (!si)
return;
soundio_disconnect(soundio);
@ -238,6 +236,9 @@ int soundio_connect_backend(SoundIo *soundio, SoundIoBackend backend) {
void soundio_disconnect(struct SoundIo *soundio) {
SoundIoPrivate *si = (SoundIoPrivate *)soundio;
if (!si)
return;
if (si->destroy)
si->destroy(si);
memset(&si->backend_data, 0, sizeof(SoundIoBackendData));

View file

@ -49,6 +49,8 @@ static void test_create_outstream(void) {
soundio_outstream_destroy(outstream);
soundio_device_unref(device);
soundio_destroy(soundio);
soundio = NULL;
soundio_destroy(soundio);
}