]> code.delx.au - pulseaudio/blobdiff - polyp/xmalloc.c
Make the whole stuff LGPL only
[pulseaudio] / polyp / xmalloc.c
index 7d8b4821e51f7884524de10a696daaa8f5e9ca35..7ddefa94fa499085e034cb41af2efa4967ed148e 100644 (file)
@@ -1,23 +1,52 @@
+/* $Id$ */
+
+/***
+  This file is part of polypaudio.
+  polypaudio is free software; you can redistribute it and/or modify
+  it under the terms of the GNU Lesser General Public License as published
+  by the Free Software Foundation; either version 2 of the License,
+  or (at your option) any later version.
+  polypaudio is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+  You should have received a copy of the GNU Lesser General Public License
+  along with polypaudio; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+  USA.
+***/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include <stdlib.h>
 #include <signal.h>
 #include <assert.h>
+#include <unistd.h>
 
 #include "memory.h"
 #include "util.h"
 
-#define MAX_ALLOC_SIZE (1024*1024*20)
+/* Make sure not to allocate more than this much memory. */
+#define MAX_ALLOC_SIZE (1024*1024*20) /* 20MB */
 
-#undef malloc
-#undef free
-#undef realloc
-#undef strndup
-#undef strdup
+/* #undef malloc */
+/* #undef free */
+/* #undef realloc */
+/* #undef strndup */
+/* #undef strdup */
 
+/** called in case of an OOM situation. Prints an error message and
+ * exits */
 static void oom(void) {
     static const char e[] = "Not enough memory\n";
-    pa_loop_write(2, e, sizeof(e)-1);
+    pa_loop_write(STDERR_FILENO, e, sizeof(e)-1);
     raise(SIGQUIT);
-    exit(1);
+    _exit(1);
 }
 
 void* pa_xmalloc(size_t size) {