changeset 36466:9824daf4a867

Simpler/more robust cleanup code.
author reimar
date Tue, 31 Dec 2013 15:31:15 +0000
parents 273702710048
children 645cbd086d2b
files libao2/ao_sndio.c
diffstat 1 files changed, 9 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/libao2/ao_sndio.c	Tue Dec 31 15:31:09 2013 +0000
+++ b/libao2/ao_sndio.c	Tue Dec 31 15:31:15 2013 +0000
@@ -112,20 +112,20 @@
     par.round = par.rate * 10 / 1000;        /*  10ms block size */
     if (!sio_setpar(hdl, &par)) {
         mp_msg(MSGT_AO, MSGL_ERR, "ao2: couldn't set params\n");
-        goto bad_close;
+        goto err_out;
     }
     if (!sio_getpar(hdl, &par)) {
         mp_msg(MSGT_AO, MSGL_ERR, "ao2: couldn't get params\n");
-        goto bad_close;
+        goto err_out;
     }
     if (par.bps != SIO_BPS(par.bits)) {
         mp_msg(MSGT_AO, MSGL_ERR, "ao2: unsupported format\n");
-        goto bad_close;
+        goto err_out;
     }
     pfds = calloc(sio_nfds(hdl), sizeof(*pfds));
     if (pfds == NULL) {
         mp_msg(MSGT_AO, MSGL_ERR, "ao2: couldn't allocate poll fds\n");
-        goto bad_close;
+        goto err_out;
     }
     bpf = par.bps * par.pchan;
     ao_data.format = af_bits2fmt(8 * par.bps);
@@ -147,13 +147,12 @@
     delay = 0;
     if (!sio_start(hdl)) {
         mp_msg(MSGT_AO, MSGL_ERR, "ao2: init: couldn't start\n");
-        goto bad_free;
+        goto err_out;
     }
     return 1;
-bad_free:
+err_out:
     free(pfds);
     pfds = NULL;
-bad_close:
     sio_close(hdl);
     hdl = NULL;
     return 0;
@@ -166,8 +165,9 @@
 {
     if (hdl)
         sio_close(hdl);
-    if (pfds)
-        free(pfds);
+    hdl = NULL;
+    free(pfds);
+    pfds = NULL;
 }
 
 /*