[xiph-commits] r12677 - trunk/ezstream/src

moritz at svn.xiph.org moritz at svn.xiph.org
Wed Mar 7 17:12:15 PST 2007


Author: moritz
Date: 2007-03-07 17:12:13 -0800 (Wed, 07 Mar 2007)
New Revision: 12677

Modified:
   trunk/ezstream/src/util.c
   trunk/ezstream/src/util.h
Log:
Replace the very broken xfree() function with an xfree() macro - the main point
was to set ptr to NULL, but the function only set the copy of ptr to NULL.
Spotted by Karl Heyes, thanks a lot!


Modified: trunk/ezstream/src/util.c
===================================================================
--- trunk/ezstream/src/util.c	2007-03-07 23:39:53 UTC (rev 12676)
+++ trunk/ezstream/src/util.c	2007-03-08 01:12:13 UTC (rev 12677)
@@ -113,19 +113,6 @@
 	return (ret);
 }
 
-void
-xfree(void *ptr)
-{
-	if (ptr == NULL) {
-		printf("%s: xfree(): Internal error: NULL argument\n",
-		       __progname);
-		abort();
-	}
-
-	free(ptr);
-	ptr = NULL;
-}
-
 char *
 xstrdup(const char *str)
 {

Modified: trunk/ezstream/src/util.h
===================================================================
--- trunk/ezstream/src/util.h	2007-03-07 23:39:53 UTC (rev 12676)
+++ trunk/ezstream/src/util.h	2007-03-08 01:12:13 UTC (rev 12677)
@@ -20,8 +20,17 @@
 void *	xmalloc(size_t /* size */);
 void *	xcalloc(size_t /* nmemb */, size_t /* size */);
 void *	xrealloc(void *, size_t /* nmemb */, size_t /* size */);
-void	xfree(void *);
 char *	xstrdup(const char *);
 int	strrcmp(const char *, const char *);
 
+#define xfree(ptr)	do {						\
+	if ((ptr) == NULL) {						\
+		printf("%s: xfree(): Internal error: NULL argument\n",	\
+		       __progname);					\
+		abort();						\
+	}								\
+	free(ptr);							\
+	(ptr) = NULL;							\
+} while (0)
+
 #endif /* __UTIL_H__ */



More information about the commits mailing list