diff options
author | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2017-01-03 07:25:17 +0000 |
---|---|---|
committer | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2017-01-03 07:25:17 +0000 |
commit | a331c813520a888e5fcf6a2077ad0013e0abbf74 (patch) | |
tree | 2f967c2be56f735232cf3b615d83f7534d2af9de /usr.bin/aucat | |
parent | 9adf992c4585625aa1a5fe517f4524cb8b33727d (diff) |
Sync utils.c and utils.h to sndiod.
Diffstat (limited to 'usr.bin/aucat')
-rw-r--r-- | usr.bin/aucat/utils.c | 22 | ||||
-rw-r--r-- | usr.bin/aucat/utils.h | 3 |
2 files changed, 21 insertions, 4 deletions
diff --git a/usr.bin/aucat/utils.c b/usr.bin/aucat/utils.c index 410efd0cb35..406204303b1 100644 --- a/usr.bin/aucat/utils.c +++ b/usr.bin/aucat/utils.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utils.c,v 1.4 2016/09/30 08:43:23 ratchov Exp $ */ +/* $OpenBSD: utils.c,v 1.5 2017/01/03 07:25:16 ratchov Exp $ */ /* * Copyright (c) 2003-2012 Alexandre Ratchov <alex@caoua.org> * @@ -24,6 +24,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <fcntl.h> #include "utils.h" /* @@ -95,7 +96,7 @@ log_putx(unsigned long num) } /* - * store a unsigned decimal in the log + * store an unsigned decimal in the log */ void log_putu(unsigned long num) @@ -139,7 +140,7 @@ panic(void) } /* - * allocate a (small) abount of memory, and abort if it fails + * allocate a (small) amount of memory, and abort if it fails */ void * xmalloc(size_t size) @@ -157,6 +158,21 @@ xmalloc(size_t size) } /* + * free memory allocated with xmalloc() + */ +void +xfree(void *p) +{ +#ifdef DEBUG + if (p == NULL) { + log_puts("xfree with NULL arg\n"); + panic(); + } +#endif + free(p); +} + +/* * xmalloc-style strdup(3) */ char * diff --git a/usr.bin/aucat/utils.h b/usr.bin/aucat/utils.h index 363ff4a7fcf..442e1b1571a 100644 --- a/usr.bin/aucat/utils.h +++ b/usr.bin/aucat/utils.h @@ -1,4 +1,4 @@ -/* $OpenBSD: utils.h,v 1.2 2015/11/09 14:44:23 mmcc Exp $ */ +/* $OpenBSD: utils.h,v 1.3 2017/01/03 07:25:16 ratchov Exp $ */ /* * Copyright (c) 2003-2012 Alexandre Ratchov <alex@caoua.org> * @@ -29,6 +29,7 @@ void log_flush(void); void *xmalloc(size_t); char *xstrdup(char *); +void xfree(void *); /* * Log levels: |