Hi tech,

during my search after other xfree() implementations, I saw that xfree() in 
sndiod is just a wrapper for free()
without any other conditions, like NULL check.

fritjof


Index: abuf.c
===================================================================
RCS file: /cvs/src/usr.bin/sndiod/abuf.c,v
retrieving revision 1.2
diff -u -p -r1.2 abuf.c
--- abuf.c      7 Dec 2012 08:04:58 -0000       1.2
+++ abuf.c      3 Aug 2014 12:37:19 -0000
@@ -62,7 +62,7 @@ abuf_done(struct abuf *buf)
                }
        }
 #endif
-       xfree(buf->data);
+       free(buf->data);
        buf->data = (void *)0xdeadbeef;
 }
 
Index: dev.c
===================================================================
RCS file: /cvs/src/usr.bin/sndiod/dev.c,v
retrieving revision 1.17
diff -u -p -r1.17 dev.c
--- dev.c       2 Jun 2014 07:51:25 -0000       1.17
+++ dev.c       3 Aug 2014 12:38:52 -0000
@@ -15,6 +15,7 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 
 #include "abuf.h"
@@ -838,10 +839,8 @@ dev_cycle(struct dev *d)
                         */
                        s->pstate = SLOT_INIT;
                        abuf_done(&s->mix.buf);
-                       if (s->mix.decbuf)
-                               xfree(s->mix.decbuf);
-                       if (s->mix.resampbuf)
-                               xfree(s->mix.resampbuf);
+                       free(s->mix.decbuf);
+                       free(s->mix.resampbuf);
                        s->ops->eof(s->arg);
                        *ps = s->next;
                        dev_mix_adjvol(d);
@@ -1143,14 +1142,12 @@ dev_close(struct dev *d)
        d->slot_list = NULL;
        dev_sio_close(d);
        if (d->mode & MODE_PLAY) {
-               if (d->encbuf != NULL)
-                       xfree(d->encbuf);
-               xfree(d->pbuf);
+               free(d->encbuf);
+               free(d->pbuf);
        }
        if (d->mode & MODE_REC) {
-               if (d->decbuf != NULL)
-                       xfree(d->decbuf);
-               xfree(d->rbuf);
+               free(d->decbuf);
+               free(d->rbuf);
        }
 }
 
@@ -1256,7 +1253,7 @@ dev_del(struct dev *d)
        }
        midi_del(d->midi);
        *p = d->next;
-       xfree(d);
+       free(d);
 }
 
 unsigned int
@@ -1829,16 +1826,12 @@ slot_detach(struct slot *s)
        }       
        *ps = s->next;
        if (s->mode & MODE_RECMASK) {
-               if (s->sub.encbuf)
-                       xfree(s->sub.encbuf);
-               if (s->sub.resampbuf)
-                       xfree(s->sub.resampbuf);
+               free(s->sub.encbuf);
+               free(s->sub.resampbuf);
        }
        if (s->mode & MODE_PLAY) {
-               if (s->mix.decbuf)
-                       xfree(s->mix.decbuf);
-               if (s->mix.resampbuf)
-                       xfree(s->mix.resampbuf);
+               free(s->mix.decbuf);
+               free(s->mix.resampbuf);
                dev_mix_adjvol(s->dev);
        }
 }
Index: file.c
===================================================================
RCS file: /cvs/src/usr.bin/sndiod/file.c,v
retrieving revision 1.5
diff -u -p -r1.5 file.c
--- file.c      17 Mar 2014 17:17:01 -0000      1.5
+++ file.c      3 Aug 2014 12:40:30 -0000
@@ -294,7 +294,7 @@ file_poll(void)
        while ((f = *pf) != NULL) {
                if (f->state == FILE_ZOMB) {
                        *pf = f->next;
-                       xfree(f);
+                       free(f);
                } else
                        pf = &f->next;
        }
Index: listen.c
===================================================================
RCS file: /cvs/src/usr.bin/sndiod/listen.c,v
retrieving revision 1.2
diff -u -p -r1.2 listen.c
--- listen.c    13 Mar 2013 08:28:33 -0000      1.2
+++ listen.c    3 Aug 2014 12:40:55 -0000
@@ -70,13 +70,13 @@ listen_close(struct listen *f)
        }
        *pf = f->next;
 
-       if (f->path != NULL) {
+       if (f->path != NULL)
                unlink(f->path);
-               xfree(f->path);
-       }
+               
+       free(f->path);
        file_del(f->file);
        close(f->fd);
-       xfree(f);
+       free(f);
 }
 
 void
Index: midi.c
===================================================================
RCS file: /cvs/src/usr.bin/sndiod/midi.c,v
retrieving revision 1.10
diff -u -p -r1.10 midi.c
--- midi.c      28 Sep 2013 18:49:32 -0000      1.10
+++ midi.c      3 Aug 2014 12:42:08 -0000
@@ -461,7 +461,7 @@ port_del(struct port *c)
 #endif
        }
        *p = c->next;
-       xfree(c);
+       free(c);
 }
 
 int
Index: opt.c
===================================================================
RCS file: /cvs/src/usr.bin/sndiod/opt.c,v
retrieving revision 1.2
diff -u -p -r1.2 opt.c
--- opt.c       7 Dec 2012 08:04:58 -0000       1.2
+++ opt.c       3 Aug 2014 12:43:52 -0000
@@ -136,5 +136,5 @@ opt_del(struct opt *o)
 #endif
        }
        *po = o->next;
-       xfree(o);
+       free(o);
 }
Index: sock.c
===================================================================
RCS file: /cvs/src/usr.bin/sndiod/sock.c,v
retrieving revision 1.13
diff -u -p -r1.13 sock.c
--- sock.c      2 Jun 2014 07:54:23 -0000       1.13
+++ sock.c      3 Aug 2014 12:45:51 -0000
@@ -152,7 +152,7 @@ sock_close(struct sock *f)
        }
        file_del(f->file);
        close(f->fd);
-       xfree(f);
+       free(f);
 }
 
 void
@@ -289,7 +289,7 @@ sock_new(int fd)
        f->file = file_new(&sock_fileops, f, "sock", 1);
        f->fd = fd;
        if (f->file == NULL) {
-               xfree(f);
+               free(f);
                return NULL;
        }
        f->next = sock_list;
Index: utils.c
===================================================================
RCS file: /cvs/src/usr.bin/sndiod/utils.c,v
retrieving revision 1.1
diff -u -p -r1.1 utils.c
--- utils.c     23 Nov 2012 07:03:28 -0000      1.1
+++ utils.c     3 Aug 2014 12:47:24 -0000
@@ -158,15 +158,6 @@ xmalloc(size_t size)
 }
 
 /*
- * free memory allocated with xmalloc()
- */
-void
-xfree(void *p)
-{
-       free(p);
-}
-
-/*
  * xmalloc-style strdup(3)
  */
 char *
Index: utils.h
===================================================================
RCS file: /cvs/src/usr.bin/sndiod/utils.h,v
retrieving revision 1.3
diff -u -p -r1.3 utils.h
--- utils.h     12 May 2013 04:58:41 -0000      1.3
+++ utils.h     3 Aug 2014 12:47:29 -0000
@@ -29,7 +29,6 @@ void log_flush(void);
 
 void *xmalloc(size_t);
 char *xstrdup(char *);
-void xfree(void *);
 
 /*
  * Log levels:

Reply via email to