[pulseaudio-commits] r1809 - in /branches/lennart/src: daemon/ modules/ pulse/ pulsecore/

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Tue Sep 11 13:48:34 PDT 2007


Author: lennart
Date: Tue Sep 11 22:48:33 2007
New Revision: 1809

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=1809&root=pulseaudio&view=rev
Log:
remaining s/assert/pa_assert/ and refcnt.h modernizations

Modified:
    branches/lennart/src/daemon/cmdline.c
    branches/lennart/src/daemon/cpulimit.c
    branches/lennart/src/daemon/dumpmodules.c
    branches/lennart/src/daemon/main.c
    branches/lennart/src/modules/alsa-util.c
    branches/lennart/src/modules/module-alsa-source.c
    branches/lennart/src/modules/module-cli.c
    branches/lennart/src/modules/module-detect.c
    branches/lennart/src/modules/module-lirc.c
    branches/lennart/src/modules/module-sine.c
    branches/lennart/src/modules/module-zeroconf-publish.c
    branches/lennart/src/pulse/glib-mainloop.c
    branches/lennart/src/pulse/subscribe.c
    branches/lennart/src/pulse/util.c
    branches/lennart/src/pulsecore/authkey-prop.c
    branches/lennart/src/pulsecore/cli-command.c
    branches/lennart/src/pulsecore/cli.c
    branches/lennart/src/pulsecore/core-scache.c
    branches/lennart/src/pulsecore/core-subscribe.c
    branches/lennart/src/pulsecore/core-util.c
    branches/lennart/src/pulsecore/dynarray.c
    branches/lennart/src/pulsecore/flist.c
    branches/lennart/src/pulsecore/hashmap.c
    branches/lennart/src/pulsecore/hook-list.c
    branches/lennart/src/pulsecore/iochannel.c
    branches/lennart/src/pulsecore/iochannel.h
    branches/lennart/src/pulsecore/ioline.c
    branches/lennart/src/pulsecore/ipacl.c
    branches/lennart/src/pulsecore/mcalign.c
    branches/lennart/src/pulsecore/memblock.c
    branches/lennart/src/pulsecore/memchunk.c
    branches/lennart/src/pulsecore/modargs.c
    branches/lennart/src/pulsecore/modinfo.c
    branches/lennart/src/pulsecore/module.c
    branches/lennart/src/pulsecore/mutex-posix.c
    branches/lennart/src/pulsecore/namereg.c
    branches/lennart/src/pulsecore/packet.c
    branches/lennart/src/pulsecore/packet.h
    branches/lennart/src/pulsecore/parseaddr.c
    branches/lennart/src/pulsecore/pdispatch.c
    branches/lennart/src/pulsecore/pid.c
    branches/lennart/src/pulsecore/props.c
    branches/lennart/src/pulsecore/protocol-cli.c
    branches/lennart/src/pulsecore/protocol-http.c
    branches/lennart/src/pulsecore/pstream-util.c
    branches/lennart/src/pulsecore/queue.c
    branches/lennart/src/pulsecore/random.c
    branches/lennart/src/pulsecore/shm.c
    branches/lennart/src/pulsecore/sink.c
    branches/lennart/src/pulsecore/sioman.c
    branches/lennart/src/pulsecore/socket-client.c
    branches/lennart/src/pulsecore/socket-server.c
    branches/lennart/src/pulsecore/socket-util.c
    branches/lennart/src/pulsecore/source.c
    branches/lennart/src/pulsecore/strbuf.c
    branches/lennart/src/pulsecore/tagstruct.c
    branches/lennart/src/pulsecore/tokenizer.c
    branches/lennart/src/pulsecore/x11prop.c
    branches/lennart/src/pulsecore/x11wrap.c

Modified: branches/lennart/src/daemon/cmdline.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/daemon/cmdline.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/daemon/cmdline.c (original)
+++ branches/lennart/src/daemon/cmdline.c Tue Sep 11 22:48:33 2007
@@ -26,7 +26,6 @@
 #endif
 
 #include <string.h>
-#include <assert.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <getopt.h>
@@ -36,6 +35,7 @@
 
 #include <pulsecore/core-util.h>
 #include <pulsecore/strbuf.h>
+#include <pulsecore/macro.h>
 
 #include "cmdline.h"
 
@@ -100,6 +100,8 @@
 void pa_cmdline_help(const char *argv0) {
     const char *e;
 
+    pa_assert(argv0);
+    
     if ((e = strrchr(argv0, '/')))
         e++;
     else
@@ -154,7 +156,10 @@
 int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d) {
     pa_strbuf *buf = NULL;
     int c;
-    assert(conf && argc && argv);
+    
+    pa_assert(conf);
+    pa_assert(argc > 0);
+    pa_assert(argv);
 
     buf = pa_strbuf_new();
 

Modified: branches/lennart/src/daemon/cpulimit.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/daemon/cpulimit.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/daemon/cpulimit.c (original)
+++ branches/lennart/src/daemon/cpulimit.c Tue Sep 11 22:48:33 2007
@@ -30,6 +30,7 @@
 #include <pulsecore/core-util.h>
 #include <pulsecore/core-error.h>
 #include <pulsecore/log.h>
+#include <pulsecore/macro.h>
 
 #include "cpulimit.h"
 
@@ -38,7 +39,6 @@
 #include <errno.h>
 #include <stdio.h>
 #include <string.h>
-#include <assert.h>
 #include <sys/time.h>
 #include <unistd.h>
 #include <signal.h>
@@ -92,23 +92,18 @@
 
 /* Reset the SIGXCPU timer to the next t seconds */
 static void reset_cpu_time(int t) {
-    int r;
     long n;
     struct rlimit rl;
     struct rusage ru;
 
     /* Get the current CPU time of the current process */
-    r = getrusage(RUSAGE_SELF, &ru);
-    assert(r >= 0);
+    pa_assert_se(getrusage(RUSAGE_SELF, &ru) >= 0);
 
     n = ru.ru_utime.tv_sec + ru.ru_stime.tv_sec + t;
-
-    r = getrlimit(RLIMIT_CPU, &rl);
-    assert(r >= 0);
+    pa_assert_se(getrlimit(RLIMIT_CPU, &rl) >= 0);
 
     rl.rlim_cur = n;
-    r = setrlimit(RLIMIT_CPU, &rl);
-    assert(r >= 0);
+    pa_assert_se(setrlimit(RLIMIT_CPU, &rl) >= 0);
 }
 
 /* A simple, thread-safe puts() work-alike */
@@ -118,7 +113,7 @@
 
 /* The signal handler, called on every SIGXCPU */
 static void signal_handler(int sig) {
-    assert(sig == SIGXCPU);
+    pa_assert(sig == SIGXCPU);
 
     if (phase == PHASE_IDLE) {
         time_t now;
@@ -160,7 +155,12 @@
 /* Callback for IO events on the FIFO */
 static void callback(pa_mainloop_api*m, pa_io_event*e, int fd, pa_io_event_flags_t f, void *userdata) {
     char c;
-    assert(m && e && f == PA_IO_EVENT_INPUT && e == io_event && fd == the_pipe[0]);
+    pa_assert(m);
+    pa_assert(e);
+    pa_assert(f == PA_IO_EVENT_INPUT);
+    pa_assert(e == io_event);
+    pa_assert(fd == the_pipe[0]);
+    
     pa_read(the_pipe[0], &c, sizeof(c), NULL);
     m->quit(m, 1); /* Quit the main loop */
 }
@@ -168,7 +168,13 @@
 /* Initializes CPU load limiter */
 int pa_cpu_limit_init(pa_mainloop_api *m) {
     struct sigaction sa;
-    assert(m && !api && !io_event && the_pipe[0] == -1 && the_pipe[1] == -1 && !installed);
+    
+    pa_assert(m);
+    pa_assert(!api);
+    pa_assert(!io_event);
+    pa_assert(the_pipe[0] == -1);
+    pa_assert(the_pipe[1] == -1);
+    pa_assert(!installed);
 
     time(&last_time);
 
@@ -208,10 +214,9 @@
 
 /* Shutdown CPU load limiter */
 void pa_cpu_limit_done(void) {
-    int r;
 
     if (io_event) {
-        assert(api);
+        pa_assert(api);
         api->io_free(io_event);
         io_event = NULL;
         api = NULL;
@@ -224,8 +229,7 @@
     the_pipe[0] = the_pipe[1] = -1;
 
     if (installed) {
-        r = sigaction(SIGXCPU, &sigaction_prev, NULL);
-        assert(r >= 0);
+        pa_assert_se(sigaction(SIGXCPU, &sigaction_prev, NULL) >= 0);
         installed = 0;
     }
 }

Modified: branches/lennart/src/daemon/dumpmodules.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/daemon/dumpmodules.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/daemon/dumpmodules.c (original)
+++ branches/lennart/src/daemon/dumpmodules.c Tue Sep 11 22:48:33 2007
@@ -28,7 +28,6 @@
 
 #include <string.h>
 #include <getopt.h>
-#include <assert.h>
 #include <stdio.h>
 #include <ltdl.h>
 
@@ -36,19 +35,23 @@
 
 #include <pulsecore/modinfo.h>
 #include <pulsecore/core-util.h>
+#include <pulsecore/macro.h>
 
 #include "dumpmodules.h"
 
 #define PREFIX "module-"
 
 static void short_info(const char *name, PA_GCC_UNUSED const char *path, pa_modinfo *i) {
-    assert(name && i);
+    pa_assert(name);
+    pa_assert(i);
+    
     printf("%-40s%s\n", name, i->description ? i->description : "n/a");
 }
 
 static void long_info(const char *name, const char *path, pa_modinfo *i) {
     static int nl = 0;
-    assert(name && i);
+    pa_assert(name);
+    pa_assert(i);
 
     if (nl)
         printf("\n");
@@ -77,6 +80,8 @@
 static void show_info(const char *name, const char *path, void (*info)(const char *name, const char *path, pa_modinfo*i)) {
     pa_modinfo *i;
 
+    pa_assert(name);
+    
     if ((i = pa_modinfo_get_by_name(path ? path : name))) {
         info(name, path, i);
         pa_modinfo_free(i);
@@ -122,6 +127,8 @@
 }
 
 void pa_dump_modules(pa_daemon_conf *c, int argc, char * const argv[]) {
+    pa_assert(c);
+    
     if (argc > 0) {
         int i;
         for (i = 0; i < argc; i++)

Modified: branches/lennart/src/daemon/main.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/daemon/main.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/daemon/main.c (original)
+++ branches/lennart/src/daemon/main.c Tue Sep 11 22:48:33 2007
@@ -33,7 +33,6 @@
 #include <stdio.h>
 #include <signal.h>
 #include <stddef.h>
-#include <assert.h>
 #include <ltdl.h>
 #include <limits.h>
 #include <fcntl.h>
@@ -287,7 +286,7 @@
 
 static void set_one_rlimit(const pa_rlimit *r, int resource, const char *name) {
     struct rlimit rl;
-    assert(r);
+    pa_assert(r);
 
     if (!r->is_set)
         return;
@@ -498,7 +497,7 @@
             goto finish;
 
         default:
-            assert(conf->cmd == PA_CMD_DAEMON);
+            pa_assert(conf->cmd == PA_CMD_DAEMON);
     }
 
     if (real_root && !conf->system_instance) {
@@ -630,8 +629,7 @@
     
     pa_rtsig_configure(SIGRTMIN+10, SIGRTMAX);
 
-    mainloop = pa_mainloop_new();
-    assert(mainloop);
+    pa_assert_se(mainloop = pa_mainloop_new());
 
     if (!(c = pa_core_new(pa_mainloop_get_api(mainloop), !conf->disable_shm))) {
         pa_log("pa_core_new() failed.");
@@ -664,9 +662,7 @@
 #endif
 
 #ifdef OS_IS_WIN32
-    timer = pa_mainloop_get_api(mainloop)->time_new(
-        pa_mainloop_get_api(mainloop), pa_gettimeofday(&tv), message_cb, NULL);
-    assert(timer);
+    pa_assert_se(timer = pa_mainloop_get_api(mainloop)->time_new(pa_mainloop_get_api(mainloop), pa_gettimeofday(&tv), message_cb, NULL));
 #endif
 
     if (conf->daemonize)
@@ -674,10 +670,8 @@
 
     oil_init();
 
-    if (!conf->no_cpu_limit) {
-        r = pa_cpu_limit_init(pa_mainloop_get_api(mainloop));
-        assert(r == 0);
-    }
+    if (!conf->no_cpu_limit)
+        pa_assert_se(pa_cpu_limit_init(pa_mainloop_get_api(mainloop)) == 0);
     
     buf = pa_strbuf_new();
     if (conf->default_script_file)

Modified: branches/lennart/src/modules/alsa-util.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/modules/alsa-util.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/modules/alsa-util.c (original)
+++ branches/lennart/src/modules/alsa-util.c Tue Sep 11 22:48:33 2007
@@ -88,7 +88,7 @@
         }
     }
 
-    assert(i != fdl->num_fds);
+    pa_assert(i != fdl->num_fds);
 
     if ((err = snd_mixer_poll_descriptors_revents(fdl->mixer, fdl->work_fds, fdl->num_fds, &revents)) < 0) {
         pa_log_error("Unable to get poll revent: %s", snd_strerror(err));

Modified: branches/lennart/src/modules/module-alsa-source.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/modules/module-alsa-source.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/modules/module-alsa-source.c (original)
+++ branches/lennart/src/modules/module-alsa-source.c Tue Sep 11 22:48:33 2007
@@ -26,7 +26,6 @@
 #include <config.h>
 #endif
 
-#include <assert.h>
 #include <stdio.h>
 
 #include <asoundlib.h>
@@ -817,7 +816,7 @@
     pa_log_info("Using %u fragments of size %lu bytes.", nfrags, (long unsigned) u->fragment_size);
 
     if (u->mixer_handle) {
-        assert(u->mixer_elem);
+        pa_assert(u->mixer_elem);
         
         if (snd_mixer_selem_has_capture_volume(u->mixer_elem)) {
             int i;

Modified: branches/lennart/src/modules/module-cli.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/modules/module-cli.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/modules/module-cli.c (original)
+++ branches/lennart/src/modules/module-cli.c Tue Sep 11 22:48:33 2007
@@ -26,7 +26,6 @@
 #endif
 
 #include <stdio.h>
-#include <assert.h>
 #include <unistd.h>
 
 #include <pulsecore/module.h>
@@ -35,6 +34,7 @@
 #include <pulsecore/sioman.h>
 #include <pulsecore/log.h>
 #include <pulsecore/modargs.h>
+#include <pulsecore/macro.h>
 
 #include "module-cli-symdef.h"
 
@@ -51,8 +51,8 @@
 static void eof_and_unload_cb(pa_cli*c, void *userdata) {
     pa_module *m = userdata;
 
-    assert(c);
-    assert(m);
+    pa_assert(c);
+    pa_assert(m);
 
     pa_module_unload_request(m);
 }
@@ -60,8 +60,8 @@
 static void eof_and_exit_cb(pa_cli*c, void *userdata) {
     pa_module *m = userdata;
 
-    assert(c);
-    assert(m);
+    pa_assert(c);
+    pa_assert(m);
 
     m->core->mainloop->quit(m->core->mainloop, 0);
 }
@@ -71,7 +71,7 @@
     pa_modargs *ma;
     int exit_on_eof = 0;
 
-    assert(m);
+    pa_assert(m);
 
     if (m->core->running_as_daemon) {
         pa_log_info("Running as daemon, refusing to load this module.");
@@ -113,7 +113,7 @@
 }
 
 void pa__done(pa_module*m) {
-    assert(m);
+    pa_assert(m);
 
     if (m->core->running_as_daemon == 0) {
         pa_cli_free(m->userdata);

Modified: branches/lennart/src/modules/module-detect.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/modules/module-detect.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/modules/module-detect.c (original)
+++ branches/lennart/src/modules/module-detect.c Tue Sep 11 22:48:33 2007
@@ -28,7 +28,6 @@
 #endif
 
 #include <stdio.h>
-#include <assert.h>
 #include <unistd.h>
 #include <string.h>
 #include <stdlib.h>
@@ -44,6 +43,7 @@
 #include <pulsecore/modargs.h>
 #include <pulsecore/log.h>
 #include <pulsecore/core-util.h>
+#include <pulsecore/macro.h>
 
 #include "module-detect-symdef.h"
 

Modified: branches/lennart/src/modules/module-lirc.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/modules/module-lirc.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/modules/module-lirc.c (original)
+++ branches/lennart/src/modules/module-lirc.c Tue Sep 11 22:48:33 2007
@@ -26,11 +26,11 @@
 #endif
 
 #include <stdio.h>
-#include <assert.h>
 #include <unistd.h>
 #include <string.h>
+#include <stdlib.h>
+
 #include <lirc/lirc_client.h>
-#include <stdlib.h>
 
 #include <pulse/xmalloc.h>
 
@@ -39,6 +39,7 @@
 #include <pulsecore/namereg.h>
 #include <pulsecore/sink.h>
 #include <pulsecore/modargs.h>
+#include <pulsecore/macro.h>
 
 #include "module-lirc-symdef.h"
 

Modified: branches/lennart/src/modules/module-sine.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/modules/module-sine.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/modules/module-sine.c (original)
+++ branches/lennart/src/modules/module-sine.c Tue Sep 11 22:48:33 2007
@@ -26,7 +26,6 @@
 #endif
 
 #include <stdio.h>
-#include <assert.h>
 #include <math.h>
 
 #include <pulse/xmalloc.h>

Modified: branches/lennart/src/modules/module-zeroconf-publish.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/modules/module-zeroconf-publish.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/modules/module-zeroconf-publish.c (original)
+++ branches/lennart/src/modules/module-zeroconf-publish.c Tue Sep 11 22:48:33 2007
@@ -26,7 +26,6 @@
 #endif
 
 #include <stdio.h>
-#include <assert.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>

Modified: branches/lennart/src/pulse/glib-mainloop.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulse/glib-mainloop.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulse/glib-mainloop.c (original)
+++ branches/lennart/src/pulse/glib-mainloop.c Tue Sep 11 22:48:33 2007
@@ -24,8 +24,6 @@
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
-
-#include <assert.h>
 
 #include <pulse/xmalloc.h>
 #include <pulse/timeval.h>

Modified: branches/lennart/src/pulse/subscribe.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulse/subscribe.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulse/subscribe.c (original)
+++ branches/lennart/src/pulse/subscribe.c Tue Sep 11 22:48:33 2007
@@ -25,7 +25,6 @@
 #include <config.h>
 #endif
 
-#include <assert.h>
 #include <stdio.h>
 
 #include <pulsecore/gccmacro.h>

Modified: branches/lennart/src/pulse/util.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulse/util.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulse/util.c (original)
+++ branches/lennart/src/pulse/util.c Tue Sep 11 22:48:33 2007
@@ -26,7 +26,6 @@
 #include <config.h>
 #endif
 
-#include <assert.h>
 #include <errno.h>
 #include <limits.h>
 #include <stdio.h>

Modified: branches/lennart/src/pulsecore/authkey-prop.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/authkey-prop.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/authkey-prop.c (original)
+++ branches/lennart/src/pulsecore/authkey-prop.c Tue Sep 11 22:48:33 2007
@@ -38,7 +38,6 @@
 
 struct authkey_data {
     PA_REFCNT_DECLARE;
-    int ref;
     size_t length;
 };
 

Modified: branches/lennart/src/pulsecore/cli-command.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/cli-command.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/cli-command.c (original)
+++ branches/lennart/src/pulsecore/cli-command.c Tue Sep 11 22:48:33 2007
@@ -28,7 +28,6 @@
 
 #include <stdio.h>
 #include <string.h>
-#include <assert.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <unistd.h>

Modified: branches/lennart/src/pulsecore/cli.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/cli.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/cli.c (original)
+++ branches/lennart/src/pulsecore/cli.c Tue Sep 11 22:48:33 2007
@@ -27,7 +27,6 @@
 
 #include <stdio.h>
 #include <string.h>
-#include <assert.h>
 #include <stdlib.h>
 
 #include <pulse/xmalloc.h>

Modified: branches/lennart/src/pulsecore/core-scache.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/core-scache.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/core-scache.c (original)
+++ branches/lennart/src/pulsecore/core-scache.c Tue Sep 11 22:48:33 2007
@@ -26,7 +26,6 @@
 #include <config.h>
 #endif
 
-#include <assert.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
@@ -60,6 +59,7 @@
 #include <pulsecore/core-util.h>
 #include <pulsecore/log.h>
 #include <pulsecore/core-error.h>
+#include <pulsecore/macro.h>
 
 #include "core-scache.h"
 
@@ -68,7 +68,10 @@
 static void timeout_callback(pa_mainloop_api *m, pa_time_event*e, PA_GCC_UNUSED const struct timeval *tv, void *userdata) {
     pa_core *c = userdata;
     struct timeval ntv;
-    assert(c && c->mainloop == m && c->scache_auto_unload_event == e);
+    
+    pa_assert(c);
+    pa_assert(c->mainloop == m);
+    pa_assert(c->scache_auto_unload_event == e);
 
     pa_scache_unload_unused(c);
 
@@ -78,7 +81,8 @@
 }
 
 static void free_entry(pa_scache_entry *e) {
-    assert(e);
+    pa_assert(e);
+    
     pa_namereg_unregister(e->core, e->name);
     pa_subscription_post(e->core, PA_SUBSCRIPTION_EVENT_SAMPLE_CACHE|PA_SUBSCRIPTION_EVENT_REMOVE, e->index);
     pa_xfree(e->name);
@@ -90,7 +94,9 @@
 
 static pa_scache_entry* scache_add_item(pa_core *c, const char *name) {
     pa_scache_entry *e;
-    assert(c && name);
+    
+    pa_assert(c);
+    pa_assert(name);
 
     if ((e = pa_namereg_get(c, name, PA_NAMEREG_SAMPLE, 0))) {
         if (e->memchunk.memblock)
@@ -98,11 +104,11 @@
 
         pa_xfree(e->filename);
 
-        assert(e->core == c);
+        pa_assert(e->core == c);
 
         pa_subscription_post(c, PA_SUBSCRIPTION_EVENT_SAMPLE_CACHE|PA_SUBSCRIPTION_EVENT_CHANGE, e->index);
     } else {
-        e = pa_xmalloc(sizeof(pa_scache_entry));
+        e = pa_xnew(pa_scache_entry, 1);
 
         if (!pa_namereg_register(c, name, PA_NAMEREG_SAMPLE, e, 1)) {
             pa_xfree(e);
@@ -114,7 +120,7 @@
 
         if (!c->scache) {
             c->scache = pa_idxset_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
-            assert(c->scache);
+            pa_assert(c->scache);
         }
 
         pa_idxset_put(c->scache, e, &e->index);
@@ -139,7 +145,9 @@
 int pa_scache_add_item(pa_core *c, const char *name, const pa_sample_spec *ss, const pa_channel_map *map, const pa_memchunk *chunk, uint32_t *idx) {
     pa_scache_entry *e;
     char st[PA_SAMPLE_SPEC_SNPRINT_MAX];
-    assert(c && name);
+    
+    pa_assert(c);
+    pa_assert(name);
 
     if (chunk && chunk->length > PA_SCACHE_ENTRY_SIZE_MAX)
         return -1;
@@ -164,9 +172,9 @@
     if (idx)
         *idx = e->index;
 
-    pa_log_debug("created sample \"%s\" (#%d), %lu bytes with sample spec %s",
+    pa_log_debug("Created sample \"%s\" (#%d), %lu bytes with sample spec %s",
                  name, e->index, (unsigned long) e->memchunk.length,
-        pa_sample_spec_snprint(st, sizeof(st), &e->sample_spec));
+                 pa_sample_spec_snprint(st, sizeof(st), &e->sample_spec));
 
     return 0;
 }
@@ -184,6 +192,10 @@
         filename = buf;
 #endif
 
+    pa_assert(c);
+    pa_assert(name);
+    pa_assert(filename);
+    
     if (pa_sound_file_load(c->mempool, filename, &ss, &map, &chunk) < 0)
         return -1;
 
@@ -203,7 +215,9 @@
         filename = buf;
 #endif
 
-    assert(c && name);
+    pa_assert(c);
+    pa_assert(name);
+    pa_assert(filename);
 
     if (!(e = scache_add_item(c, name)))
         return -1;
@@ -226,15 +240,17 @@
 
 int pa_scache_remove_item(pa_core *c, const char *name) {
     pa_scache_entry *e;
-    assert(c && name);
+    
+    pa_assert(c);
+    pa_assert(name);
 
     if (!(e = pa_namereg_get(c, name, PA_NAMEREG_SAMPLE, 0)))
         return -1;
 
     if (pa_idxset_remove_by_data(c->scache, e, NULL) != e)
-        assert(0);
-
-    pa_log_debug("removed sample \"%s\"", name);
+        pa_assert(0);
+
+    pa_log_debug("Removed sample \"%s\"", name);
 
     free_entry(e);
 
@@ -243,12 +259,13 @@
 
 static void free_cb(void *p, PA_GCC_UNUSED void *userdata) {
     pa_scache_entry *e = p;
-    assert(e);
+    pa_assert(e);
+    
     free_entry(e);
 }
 
 void pa_scache_free(pa_core *c) {
-    assert(c);
+    pa_assert(c);
 
     if (c->scache) {
         pa_idxset_free(c->scache, free_cb, NULL);
@@ -264,9 +281,9 @@
     char *t;
     pa_cvolume r;
 
-    assert(c);
-    assert(name);
-    assert(sink);
+    pa_assert(c);
+    pa_assert(name);
+    pa_assert(sink);
 
     if (!(e = pa_namereg_get(c, name, PA_NAMEREG_SAMPLE, 1)))
         return -1;
@@ -284,7 +301,7 @@
     if (!e->memchunk.memblock)
         return -1;
 
-    pa_log_debug("playing sample \"%s\" on \"%s\"", name, sink->name);
+    pa_log_debug("Playing sample \"%s\" on \"%s\"", name, sink->name);
 
     t = pa_sprintf_malloc("sample:%s", name);
 
@@ -318,7 +335,9 @@
 
 const char * pa_scache_get_name_by_id(pa_core *c, uint32_t id) {
     pa_scache_entry *e;
-    assert(c && id != PA_IDXSET_INVALID);
+    
+    pa_assert(c);
+    pa_assert(id != PA_IDXSET_INVALID);
 
     if (!c->scache || !(e = pa_idxset_get_by_index(c->scache, id)))
         return NULL;
@@ -328,7 +347,9 @@
 
 uint32_t pa_scache_get_id_by_name(pa_core *c, const char *name) {
     pa_scache_entry *e;
-    assert(c && name);
+    
+    pa_assert(c);
+    pa_assert(name);
 
     if (!(e = pa_namereg_get(c, name, PA_NAMEREG_SAMPLE, 0)))
         return PA_IDXSET_INVALID;
@@ -339,7 +360,8 @@
 uint32_t pa_scache_total_size(pa_core *c) {
     pa_scache_entry *e;
     uint32_t idx, sum = 0;
-    assert(c);
+    
+    pa_assert(c);
 
     if (!c->scache || !pa_idxset_size(c->scache))
         return 0;
@@ -355,7 +377,8 @@
     pa_scache_entry *e;
     time_t now;
     uint32_t idx;
-    assert(c);
+
+    pa_assert(c);
 
     if (!c->scache || !pa_idxset_size(c->scache))
         return;
@@ -382,6 +405,9 @@
     struct stat st;
     const char *e;
 
+    pa_core_assert_ref(c);
+    pa_assert(pathname);
+    
     e = pa_path_get_filename(pathname);
 
     if (stat(pathname, &st) < 0) {
@@ -397,7 +423,9 @@
 
 int pa_scache_add_directory_lazy(pa_core *c, const char *pathname) {
     DIR *dir;
-    assert(c && pathname);
+    
+    pa_core_assert_ref(c);
+    pa_assert(pathname);
 
     /* First try to open this as directory */
     if (!(dir = opendir(pathname))) {

Modified: branches/lennart/src/pulsecore/core-subscribe.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/core-subscribe.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/core-subscribe.c (original)
+++ branches/lennart/src/pulsecore/core-subscribe.c Tue Sep 11 22:48:33 2007
@@ -26,12 +26,12 @@
 #endif
 
 #include <stdio.h>
-#include <assert.h>
 
 #include <pulse/xmalloc.h>
 
 #include <pulsecore/queue.h>
 #include <pulsecore/log.h>
+#include <pulsecore/macro.h>
 
 #include "core-subscribe.h"
 
@@ -68,9 +68,9 @@
 pa_subscription* pa_subscription_new(pa_core *c, pa_subscription_mask_t m, pa_subscription_cb_t callback, void *userdata) {
     pa_subscription *s;
 
-    assert(c);
-    assert(m);
-    assert(callback);
+    pa_assert(c);
+    pa_assert(m);
+    pa_assert(callback);
 
     s = pa_xnew(pa_subscription, 1);
     s->core = c;
@@ -85,24 +85,24 @@
 
 /* Free a subscription object, effectively marking it for deletion */
 void pa_subscription_free(pa_subscription*s) {
-    assert(s);
-    assert(!s->dead);
+    pa_assert(s);
+    pa_assert(!s->dead);
 
     s->dead = 1;
     sched_event(s->core);
 }
 
 static void free_subscription(pa_subscription *s) {
-    assert(s);
-    assert(s->core);
+    pa_assert(s);
+    pa_assert(s->core);
 
     PA_LLIST_REMOVE(pa_subscription, s->core->subscriptions, s);
     pa_xfree(s);
 }
 
 static void free_event(pa_subscription_event *s) {
-    assert(s);
-    assert(s->core);
+    pa_assert(s);
+    pa_assert(s->core);
 
     if (!s->next)
         s->core->subscription_event_last = s->prev;
@@ -113,7 +113,7 @@
 
 /* Free all subscription objects */
 void pa_subscription_free_all(pa_core *c) {
-    assert(c);
+    pa_assert(c);
 
     while (c->subscriptions)
         free_subscription(c->subscriptions);
@@ -160,9 +160,9 @@
     pa_core *c = userdata;
     pa_subscription *s;
 
-    assert(c->mainloop == m);
-    assert(c);
-    assert(c->subscription_defer_event == de);
+    pa_assert(c->mainloop == m);
+    pa_assert(c);
+    pa_assert(c->subscription_defer_event == de);
 
     c->mainloop->defer_enable(c->subscription_defer_event, 0);
 
@@ -196,11 +196,11 @@
 
 /* Schedule an mainloop event so that a pending subscription event is dispatched */
 static void sched_event(pa_core *c) {
-    assert(c);
+    pa_assert(c);
 
     if (!c->subscription_defer_event) {
         c->subscription_defer_event = c->mainloop->defer_new(c->mainloop, defer_cb, c);
-        assert(c->subscription_defer_event);
+        pa_assert(c->subscription_defer_event);
     }
 
     c->mainloop->defer_enable(c->subscription_defer_event, 1);
@@ -209,7 +209,7 @@
 /* Append a new subscription event to the subscription event queue and schedule a main loop event */
 void pa_subscription_post(pa_core *c, pa_subscription_event_type_t t, uint32_t idx) {
     pa_subscription_event *e;
-    assert(c);
+    pa_assert(c);
 
     /* No need for queuing subscriptions of noone is listening */
     if (!c->subscriptions)

Modified: branches/lennart/src/pulsecore/core-util.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/core-util.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/core-util.c (original)
+++ branches/lennart/src/pulsecore/core-util.c Tue Sep 11 22:48:33 2007
@@ -132,7 +132,7 @@
 void pa_make_nonblock_fd(int fd) {
 #ifdef O_NONBLOCK
     int v;
-    assert(fd >= 0);
+    pa_assert(fd >= 0);
 
     if ((v = fcntl(fd, F_GETFL)) >= 0)
         if (!(v & O_NONBLOCK))
@@ -153,7 +153,7 @@
     struct stat st;
     int r;
 
-    assert(dir);
+    pa_assert(dir);
 
 #ifdef OS_IS_WIN32
     r = mkdir(dir);
@@ -300,9 +300,9 @@
     ssize_t ret = 0;
     int _type;
 
-    assert(fd >= 0);
-    assert(data);
-    assert(size);
+    pa_assert(fd >= 0);
+    pa_assert(data);
+    pa_assert(size);
 
     if (!type) {
         _type = 0;
@@ -331,9 +331,9 @@
     ssize_t ret = 0;
     int _type;
 
-    assert(fd >= 0);
-    assert(data);
-    assert(size);
+    pa_assert(fd >= 0);
+    pa_assert(data);
+    pa_assert(size);
 
     if (!type) {
         _type = 0;
@@ -423,7 +423,7 @@
     int  size = 100;
     char *c = NULL;
 
-    assert(format);
+    pa_assert(format);
 
     for(;;) {
         int r;
@@ -453,7 +453,7 @@
     int  size = 100;
     char *c = NULL;
 
-    assert(format);
+    pa_assert(format);
 
     for(;;) {
         int r;
@@ -479,7 +479,9 @@
 
 /* Similar to OpenBSD's strlcpy() function */
 char *pa_strlcpy(char *b, const char *s, size_t l) {
-    assert(b && s && l > 0);
+    pa_assert(b);
+    pa_assert(s);
+    pa_assert(l > 0);
 
     strncpy(b, s, l);
     b[l-1] = 0;
@@ -550,7 +552,7 @@
 
 #ifdef FD_CLOEXEC
     int v;
-    assert(fd >= 0);
+    pa_assert(fd >= 0);
 
     if ((v = fcntl(fd, F_GETFD, 0)) < 0)
         return -1;
@@ -690,7 +692,7 @@
     int n = sysconf(_SC_NGROUPS_MAX);
     int r = -1, i;
 
-    assert(n > 0);
+    pa_assert(n > 0);
 
     gids = pa_xmalloc(sizeof(GETGROUPS_T)*n);
 
@@ -856,7 +858,7 @@
 
 /* Remove trailing newlines from a string */
 char* pa_strip_nl(char *s) {
-    assert(s);
+    pa_assert(s);
 
     s[strcspn(s, "\r\n")] = 0;
     return s;
@@ -865,7 +867,7 @@
 /* Create a temporary lock file and lock it. */
 int pa_lock_lockfile(const char *fn) {
     int fd = -1;
-    assert(fn);
+    pa_assert(fn);
 
     for (;;) {
         struct stat st;
@@ -916,7 +918,8 @@
 /* Unlock a temporary lcok file */
 int pa_unlock_lockfile(const char *fn, int fd) {
     int r = 0;
-    assert(fn && fd >= 0);
+    pa_assert(fn);
+    pa_assert(fd >= 0);
 
     if (unlink(fn) < 0) {
         pa_log_warn("WARNING: unable to remove lock file '%s': %s",
@@ -1026,7 +1029,10 @@
 char *pa_hexstr(const uint8_t* d, size_t dlength, char *s, size_t slength) {
     size_t i = 0, j = 0;
     const char hex[] = "0123456789abcdef";
-    assert(d && s && slength > 0);
+
+    pa_assert(d);
+    pa_assert(s);
+    pa_assert(slength > 0);
 
     while (i < dlength && j+3 <= slength) {
         s[j++] = hex[*d >> 4];
@@ -1057,7 +1063,9 @@
 /* Parse a hexadecimal string as created by pa_hexstr() to a BLOB */
 size_t pa_parsehex(const char *p, uint8_t *d, size_t dlength) {
     size_t j = 0;
-    assert(p && d);
+    
+    pa_assert(p);
+    pa_assert(d);
 
     while (j < dlength && *p) {
         int b;
@@ -1084,8 +1092,8 @@
 int pa_startswith(const char *s, const char *pfx) {
     size_t l;
 
-    assert(s);
-    assert(pfx);
+    pa_assert(s);
+    pa_assert(pfx);
 
     l = strlen(pfx);
 
@@ -1096,8 +1104,8 @@
 int pa_endswith(const char *s, const char *sfx) {
     size_t l1, l2;
 
-    assert(s);
-    assert(sfx);
+    pa_assert(s);
+    pa_assert(sfx);
 
     l1 = strlen(s);
     l2 = strlen(sfx);
@@ -1150,7 +1158,9 @@
 int pa_atoi(const char *s, int32_t *ret_i) {
     char *x = NULL;
     long l;
-    assert(s && ret_i);
+    
+    pa_assert(s);
+    pa_assert(ret_i);
 
     l = strtol(s, &x, 0);
 
@@ -1166,7 +1176,9 @@
 int pa_atou(const char *s, uint32_t *ret_u) {
     char *x = NULL;
     unsigned long l;
-    assert(s && ret_u);
+    
+    pa_assert(s);
+    pa_assert(ret_u);
 
     l = strtoul(s, &x, 0);
 

Modified: branches/lennart/src/pulsecore/dynarray.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/dynarray.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/dynarray.c (original)
+++ branches/lennart/src/pulsecore/dynarray.c Tue Sep 11 22:48:33 2007
@@ -26,10 +26,10 @@
 #endif
 
 #include <string.h>
-#include <assert.h>
 #include <stdlib.h>
 
 #include <pulse/xmalloc.h>
+#include <pulsecore/macro.h>
 
 #include "dynarray.h"
 
@@ -52,7 +52,7 @@
 
 void pa_dynarray_free(pa_dynarray* a, void (*func)(void *p, void *userdata), void *userdata) {
     unsigned i;
-    assert(a);
+    pa_assert(a);
 
     if (func)
         for (i = 0; i < a->n_entries; i++)
@@ -64,7 +64,7 @@
 }
 
 void pa_dynarray_put(pa_dynarray*a, unsigned i, void *p) {
-    assert(a);
+    pa_assert(a);
 
     if (i >= a->n_allocated) {
         unsigned n;
@@ -85,21 +85,27 @@
 }
 
 unsigned pa_dynarray_append(pa_dynarray*a, void *p) {
-    unsigned i = a->n_entries;
+    unsigned i;
+
+    pa_assert(a);
+    
+    i = a->n_entries;
     pa_dynarray_put(a, i, p);
     return i;
 }
 
 void *pa_dynarray_get(pa_dynarray*a, unsigned i) {
-    assert(a);
+    pa_assert(a);
+    
     if (i >= a->n_entries)
         return NULL;
 
-    assert(a->data);
+    pa_assert(a->data);
     return a->data[i];
 }
 
 unsigned pa_dynarray_size(pa_dynarray*a) {
-    assert(a);
+    pa_assert(a);
+    
     return a->n_entries;
 }

Modified: branches/lennart/src/pulsecore/flist.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/flist.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/flist.c (original)
+++ branches/lennart/src/pulsecore/flist.c Tue Sep 11 22:48:33 2007
@@ -25,14 +25,14 @@
 #include <config.h>
 #endif
 
-#include <assert.h>
+#include <pulse/xmalloc.h>
 
 #include <pulsecore/atomic.h>
 #include <pulsecore/log.h>
 #include <pulsecore/thread.h>
 #include <pulsecore/macro.h>
 #include <pulsecore/core-util.h>
-#include <pulse/xmalloc.h>
+#include <pulsecore/macro.h>
 
 #include "flist.h"
 
@@ -111,7 +111,7 @@
     if (!size)
         size = FLIST_SIZE;
 
-    assert(pa_is_power_of_two(size));
+    pa_assert(pa_is_power_of_two(size));
 
     l = pa_xmalloc0(PA_ALIGN(sizeof(pa_flist)) + (sizeof(struct cell) * size));
 
@@ -129,7 +129,7 @@
 }
 
 void pa_flist_free(pa_flist *l, pa_free_cb_t free_cb) {
-    assert(l);
+    pa_assert(l);
 
     if (free_cb) {
         struct cell *cells;
@@ -156,8 +156,8 @@
     int idx, len, n;
     struct cell *cells;
 
-    assert(l);
-    assert(p);
+    pa_assert(l);
+    pa_assert(p);
 
     cells = PA_FLIST_CELLS(l);
 
@@ -196,7 +196,7 @@
     int idx, len, n;
     struct cell *cells;
 
-    assert(l);
+    pa_assert(l);
 
     cells = PA_FLIST_CELLS(l);
 

Modified: branches/lennart/src/pulsecore/hashmap.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/hashmap.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/hashmap.c (original)
+++ branches/lennart/src/pulsecore/hashmap.c Tue Sep 11 22:48:33 2007
@@ -26,7 +26,6 @@
 #endif
 
 #include <stdlib.h>
-#include <assert.h>
 #include <string.h>
 
 #include <pulse/xmalloc.h>
@@ -34,6 +33,7 @@
 #include <pulsecore/idxset.h>
 #include <pulsecore/log.h>
 #include <pulsecore/flist.h>
+#include <pulsecore/macro.h>
 
 #include "hashmap.h"
 
@@ -72,8 +72,8 @@
 }
 
 static void remove(pa_hashmap *h, struct hashmap_entry *e) {
-    assert(h);
-    assert(e);
+    pa_assert(h);
+    pa_assert(e);
 
     if (e->next)
         e->next->previous = e->previous;
@@ -87,7 +87,7 @@
     if (e->bucket_previous)
         e->bucket_previous->bucket_next = e->bucket_next;
     else {
-        assert(e->hash < h->size);
+        pa_assert(e->hash < h->size);
         h->data[e->hash] = e->bucket_next;
     }
 
@@ -98,7 +98,7 @@
 }
 
 void pa_hashmap_free(pa_hashmap*h, void (*free_func)(void *p, void *userdata), void *userdata) {
-    assert(h);
+    pa_assert(h);
 
     while (h->first_entry) {
         if (free_func)
@@ -112,8 +112,8 @@
 
 static struct hashmap_entry *get(pa_hashmap *h, unsigned hash, const void *key) {
     struct hashmap_entry *e;
-    assert(h);
-    assert(hash < h->size);
+    pa_assert(h);
+    pa_assert(hash < h->size);
 
     for (e = h->data[hash]; e; e = e->bucket_next)
         if (h->compare_func(e->key, key) == 0)
@@ -125,7 +125,7 @@
 int pa_hashmap_put(pa_hashmap *h, const void *key, void *value) {
     struct hashmap_entry *e;
     unsigned hash;
-    assert(h);
+    pa_assert(h);
 
     hash = h->hash_func(key) % h->size;
 
@@ -159,7 +159,7 @@
     unsigned hash;
     struct hashmap_entry *e;
 
-    assert(h);
+    pa_assert(h);
 
     hash = h->hash_func(key) % h->size;
 
@@ -174,7 +174,7 @@
     unsigned hash;
     void *data;
 
-    assert(h);
+    pa_assert(h);
 
     hash = h->hash_func(key) % h->size;
 
@@ -191,8 +191,8 @@
 }
 
 void *pa_hashmap_iterate(pa_hashmap *h, void **state, const void **key) {
-    assert(h);
-    assert(state);
+    pa_assert(h);
+    pa_assert(state);
 
     if (!*state)
         *state = h->first_entry;
@@ -214,7 +214,7 @@
 void* pa_hashmap_steal_first(pa_hashmap *h) {
     void *data;
 
-    assert(h);
+    pa_assert(h);
 
     if (!h->first_entry)
         return NULL;
@@ -225,7 +225,7 @@
 }
 
 void *pa_hashmap_get_first(pa_hashmap *h) {
-    assert(h);
+    pa_assert(h);
 
     if (!h->first_entry)
         return NULL;

Modified: branches/lennart/src/pulsecore/hook-list.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/hook-list.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/hook-list.c (original)
+++ branches/lennart/src/pulsecore/hook-list.c Tue Sep 11 22:48:33 2007
@@ -21,10 +21,16 @@
   USA.
 ***/
 
-#include <pulsecore/hook-list.h>
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <pulsecore/macro.h>
+
+#include "hook-list.h"
 
 void pa_hook_init(pa_hook *hook, void *data) {
-    assert(hook);
+    pa_assert(hook);
 
     PA_LLIST_HEAD_INIT(pa_hook_slot, hook->slots);
     hook->last = NULL;
@@ -33,8 +39,8 @@
 }
 
 static void slot_free(pa_hook *hook, pa_hook_slot *slot) {
-    assert(hook);
-    assert(slot);
+    pa_assert(hook);
+    pa_assert(slot);
 
     if (hook->last == slot)
         hook->last = slot->prev;
@@ -45,8 +51,8 @@
 }
 
 void pa_hook_free(pa_hook *hook) {
-    assert(hook);
-    assert(!hook->firing);
+    pa_assert(hook);
+    pa_assert(!hook->firing);
 
     while (hook->slots)
         slot_free(hook, hook->slots);
@@ -57,7 +63,7 @@
 pa_hook_slot* pa_hook_connect(pa_hook *hook, pa_hook_cb_t cb, void *data) {
     pa_hook_slot *slot;
 
-    assert(cb);
+    pa_assert(cb);
 
     slot = pa_xnew(pa_hook_slot, 1);
     slot->hook = hook;
@@ -72,8 +78,8 @@
 }
 
 void pa_hook_slot_free(pa_hook_slot *slot) {
-    assert(slot);
-    assert(!slot->dead);
+    pa_assert(slot);
+    pa_assert(!slot->dead);
 
     if (slot->hook->firing > 0) {
         slot->dead = 1;
@@ -86,7 +92,7 @@
     pa_hook_slot *slot, *next;
     pa_hook_result_t result = PA_HOOK_OK;
 
-    assert(hook);
+    pa_assert(hook);
 
     hook->firing ++;
 

Modified: branches/lennart/src/pulsecore/iochannel.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/iochannel.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/iochannel.c (original)
+++ branches/lennart/src/pulsecore/iochannel.c Tue Sep 11 22:48:33 2007
@@ -27,7 +27,6 @@
 #endif
 
 #include <stdlib.h>
-#include <assert.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <errno.h>
@@ -47,6 +46,7 @@
 #include <pulsecore/core-util.h>
 #include <pulsecore/socket-util.h>
 #include <pulsecore/log.h>
+#include <pulsecore/macro.h>
 
 #include "iochannel.h"
 
@@ -68,11 +68,11 @@
 };
 
 static void enable_mainloop_sources(pa_iochannel *io) {
-    assert(io);
+    pa_assert(io);
 
     if (io->input_event == io->output_event && io->input_event) {
         pa_io_event_flags_t f = PA_IO_EVENT_NULL;
-        assert(io->input_event);
+        pa_assert(io->input_event);
 
         if (!io->readable)
             f |= PA_IO_EVENT_INPUT;
@@ -92,10 +92,10 @@
     pa_iochannel *io = userdata;
     int changed = 0;
 
-    assert(m);
-    assert(e);
-    assert(fd >= 0);
-    assert(userdata);
+    pa_assert(m);
+    pa_assert(e);
+    pa_assert(fd >= 0);
+    pa_assert(userdata);
 
     if ((f & (PA_IO_EVENT_HANGUP|PA_IO_EVENT_ERROR)) && !io->hungup) {
         io->hungup = 1;
@@ -105,13 +105,13 @@
     if ((f & PA_IO_EVENT_INPUT) && !io->readable) {
         io->readable = 1;
         changed = 1;
-        assert(e == io->input_event);
+        pa_assert(e == io->input_event);
     }
 
     if ((f & PA_IO_EVENT_OUTPUT) && !io->writable) {
         io->writable = 1;
         changed = 1;
-        assert(e == io->output_event);
+        pa_assert(e == io->output_event);
     }
 
     if (changed) {
@@ -125,8 +125,8 @@
 pa_iochannel* pa_iochannel_new(pa_mainloop_api*m, int ifd, int ofd) {
     pa_iochannel *io;
 
-    assert(m);
-    assert(ifd >= 0 || ofd >= 0);
+    pa_assert(m);
+    pa_assert(ifd >= 0 || ofd >= 0);
 
     io = pa_xnew(pa_iochannel, 1);
     io->ifd = ifd;
@@ -144,7 +144,7 @@
     io->input_event = io->output_event = NULL;
 
     if (ifd == ofd) {
-        assert(ifd >= 0);
+        pa_assert(ifd >= 0);
         pa_make_nonblock_fd(io->ifd);
         io->input_event = io->output_event = m->io_new(m, ifd, PA_IO_EVENT_INPUT|PA_IO_EVENT_OUTPUT, callback, io);
     } else {
@@ -164,7 +164,7 @@
 }
 
 void pa_iochannel_free(pa_iochannel*io) {
-    assert(io);
+    pa_assert(io);
 
     if (io->input_event)
         io->mainloop->io_free(io->input_event);
@@ -183,19 +183,19 @@
 }
 
 int pa_iochannel_is_readable(pa_iochannel*io) {
-    assert(io);
+    pa_assert(io);
 
     return io->readable || io->hungup;
 }
 
 int pa_iochannel_is_writable(pa_iochannel*io) {
-    assert(io);
+    pa_assert(io);
 
     return io->writable && !io->hungup;
 }
 
 int pa_iochannel_is_hungup(pa_iochannel*io) {
-    assert(io);
+    pa_assert(io);
 
     return io->hungup;
 }
@@ -203,10 +203,10 @@
 ssize_t pa_iochannel_write(pa_iochannel*io, const void*data, size_t l) {
     ssize_t r;
 
-    assert(io);
-    assert(data);
-    assert(l);
-    assert(io->ofd >= 0);
+    pa_assert(io);
+    pa_assert(data);
+    pa_assert(l);
+    pa_assert(io->ofd >= 0);
 
     r = pa_write(io->ofd, data, l, &io->ofd_type);
     if (r >= 0) {
@@ -220,9 +220,9 @@
 ssize_t pa_iochannel_read(pa_iochannel*io, void*data, size_t l) {
     ssize_t r;
 
-    assert(io);
-    assert(data);
-    assert(io->ifd >= 0);
+    pa_assert(io);
+    pa_assert(data);
+    pa_assert(io->ifd >= 0);
 
     r = pa_read(io->ifd, data, l, &io->ifd_type);
     if (r >= 0) {
@@ -239,9 +239,9 @@
     struct sockaddr_un sa;
     socklen_t l;
 
-    assert(io);
-    assert(io->ifd >= 0);
-    assert(io->ofd == io->ifd);
+    pa_assert(io);
+    pa_assert(io->ifd >= 0);
+    pa_assert(io->ofd == io->ifd);
 
     l = sizeof(sa);
 
@@ -254,8 +254,8 @@
 int pa_iochannel_creds_enable(pa_iochannel *io) {
     int t = 1;
 
-    assert(io);
-    assert(io->ifd >= 0);
+    pa_assert(io);
+    pa_assert(io->ifd >= 0);
 
     if (setsockopt(io->ifd, SOL_SOCKET, SO_PASSCRED, &t, sizeof(t)) < 0) {
         pa_log_error("setsockopt(SOL_SOCKET, SO_PASSCRED): %s", pa_cstrerror(errno));
@@ -273,10 +273,10 @@
     struct ucred *u;
     struct cmsghdr *cmsg;
 
-    assert(io);
-    assert(data);
-    assert(l);
-    assert(io->ofd >= 0);
+    pa_assert(io);
+    pa_assert(data);
+    pa_assert(l);
+    pa_assert(io->ofd >= 0);
 
     memset(&iov, 0, sizeof(iov));
     iov.iov_base = (void*) data;
@@ -322,12 +322,12 @@
     struct iovec iov;
     uint8_t cmsg_data[CMSG_SPACE(sizeof(struct ucred))];
 
-    assert(io);
-    assert(data);
-    assert(l);
-    assert(io->ifd >= 0);
-    assert(creds);
-    assert(creds_valid);
+    pa_assert(io);
+    pa_assert(data);
+    pa_assert(l);
+    pa_assert(io->ifd >= 0);
+    pa_assert(creds);
+    pa_assert(creds_valid);
 
     memset(&iov, 0, sizeof(iov));
     iov.iov_base = data;
@@ -353,7 +353,7 @@
 
             if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_CREDENTIALS) {
                 struct ucred u;
-                assert(cmsg->cmsg_len == CMSG_LEN(sizeof(struct ucred)));
+                pa_assert(cmsg->cmsg_len == CMSG_LEN(sizeof(struct ucred)));
                 memcpy(&u, CMSG_DATA(cmsg), sizeof(struct ucred));
 
                 creds->gid = u.gid;
@@ -373,46 +373,46 @@
 #endif /* HAVE_CREDS */
 
 void pa_iochannel_set_callback(pa_iochannel*io, pa_iochannel_cb_t _callback, void *userdata) {
-    assert(io);
+    pa_assert(io);
 
     io->callback = _callback;
     io->userdata = userdata;
 }
 
 void pa_iochannel_set_noclose(pa_iochannel*io, int b) {
-    assert(io);
+    pa_assert(io);
 
     io->no_close = b;
 }
 
 void pa_iochannel_socket_peer_to_string(pa_iochannel*io, char*s, size_t l) {
-    assert(io);
-    assert(s);
-    assert(l);
+    pa_assert(io);
+    pa_assert(s);
+    pa_assert(l);
 
     pa_socket_peer_to_string(io->ifd, s, l);
 }
 
 int pa_iochannel_socket_set_rcvbuf(pa_iochannel *io, size_t l) {
-    assert(io);
+    pa_assert(io);
 
     return pa_socket_set_rcvbuf(io->ifd, l);
 }
 
 int pa_iochannel_socket_set_sndbuf(pa_iochannel *io, size_t l) {
-    assert(io);
+    pa_assert(io);
 
     return pa_socket_set_sndbuf(io->ofd, l);
 }
 
 pa_mainloop_api* pa_iochannel_get_mainloop_api(pa_iochannel *io) {
-    assert(io);
+    pa_assert(io);
 
     return io->mainloop;
 }
 
 int pa_iochannel_get_recv_fd(pa_iochannel *io) {
-    assert(io);
+    pa_assert(io);
 
     return io->ifd;
 }

Modified: branches/lennart/src/pulsecore/iochannel.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/iochannel.h?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/iochannel.h (original)
+++ branches/lennart/src/pulsecore/iochannel.h Tue Sep 11 22:48:33 2007
@@ -24,6 +24,10 @@
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
+
+#ifndef PACKAGE
+#error "Please include config.h before including this file!"
+#endif
 
 #include <sys/types.h>
 

Modified: branches/lennart/src/pulsecore/ioline.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/ioline.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/ioline.c (original)
+++ branches/lennart/src/pulsecore/ioline.c Tue Sep 11 22:48:33 2007
@@ -27,7 +27,6 @@
 
 #include <errno.h>
 #include <stdio.h>
-#include <assert.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -35,6 +34,8 @@
 
 #include <pulsecore/core-error.h>
 #include <pulsecore/log.h>
+#include <pulsecore/macro.h>
+#include <pulsecore/refcnt.h>
 
 #include "ioline.h"
 
@@ -42,10 +43,11 @@
 #define READ_SIZE (1024)
 
 struct pa_ioline {
+    PA_REFCNT_DECLARE;
+    
     pa_iochannel *io;
     pa_defer_event *defer_event;
     pa_mainloop_api *mainloop;
-    int ref;
     int dead;
 
     char *wbuf;
@@ -65,9 +67,10 @@
 
 pa_ioline* pa_ioline_new(pa_iochannel *io) {
     pa_ioline *l;
-    assert(io);
+    pa_assert(io);
 
     l = pa_xnew(pa_ioline, 1);
+    PA_REFCNT_INIT(l);
     l->io = io;
     l->dead = 0;
 
@@ -79,7 +82,6 @@
 
     l->callback = NULL;
     l->userdata = NULL;
-    l->ref = 1;
 
     l->mainloop = pa_iochannel_get_mainloop_api(io);
 
@@ -94,7 +96,7 @@
 }
 
 static void ioline_free(pa_ioline *l) {
-    assert(l);
+    pa_assert(l);
 
     if (l->io)
         pa_iochannel_free(l->io);
@@ -108,24 +110,24 @@
 }
 
 void pa_ioline_unref(pa_ioline *l) {
-    assert(l);
-    assert(l->ref >= 1);
-
-    if ((--l->ref) <= 0)
+    pa_assert(l);
+    pa_assert(PA_REFCNT_VALUE(l) >= 1);
+
+    if (PA_REFCNT_DEC(l) <= 0)
         ioline_free(l);
 }
 
 pa_ioline* pa_ioline_ref(pa_ioline *l) {
-    assert(l);
-    assert(l->ref >= 1);
-
-    l->ref++;
+    pa_assert(l);
+    pa_assert(PA_REFCNT_VALUE(l) >= 1);
+
+    PA_REFCNT_INC(l);
     return l;
 }
 
 void pa_ioline_close(pa_ioline *l) {
-    assert(l);
-    assert(l->ref >= 1);
+    pa_assert(l);
+    pa_assert(PA_REFCNT_VALUE(l) >= 1);
 
     l->dead = 1;
 
@@ -146,9 +148,9 @@
 void pa_ioline_puts(pa_ioline *l, const char *c) {
     size_t len;
 
-    assert(l);
-    assert(l->ref >= 1);
-    assert(c);
+    pa_assert(l);
+    pa_assert(PA_REFCNT_VALUE(l) >= 1);
+    pa_assert(c);
 
     if (l->dead)
         return;
@@ -158,7 +160,7 @@
         len = BUFFER_LIMIT - l->wbuf_valid_length;
 
     if (len) {
-        assert(l->wbuf_length >= l->wbuf_valid_length);
+        pa_assert(l->wbuf_length >= l->wbuf_valid_length);
 
         /* In case the allocated buffer is too small, enlarge it. */
         if (l->wbuf_valid_length + len > l->wbuf_length) {
@@ -178,7 +180,7 @@
             l->wbuf_index = 0;
         }
 
-        assert(l->wbuf_index + l->wbuf_valid_length + len <= l->wbuf_length);
+        pa_assert(l->wbuf_index + l->wbuf_valid_length + len <= l->wbuf_length);
 
         /* Append the new string */
         memcpy(l->wbuf + l->wbuf_index + l->wbuf_valid_length, c, len);
@@ -189,17 +191,17 @@
 }
 
 void pa_ioline_set_callback(pa_ioline*l, void (*callback)(pa_ioline*io, const char *s, void *userdata), void *userdata) {
-    assert(l);
-    assert(l->ref >= 1);
+    pa_assert(l);
+    pa_assert(PA_REFCNT_VALUE(l) >= 1);
 
     l->callback = callback;
     l->userdata = userdata;
 }
 
 static void failure(pa_ioline *l, int process_leftover) {
-    assert(l);
-    assert(l->ref >= 1);
-    assert(!l->dead);
+    pa_assert(l);
+    pa_assert(PA_REFCNT_VALUE(l) >= 1);
+    pa_assert(!l->dead);
 
     if (process_leftover && l->rbuf_valid_length > 0) {
         /* Pass the last missing bit to the client */
@@ -220,7 +222,9 @@
 }
 
 static void scan_for_lines(pa_ioline *l, size_t skip) {
-    assert(l && l->ref >= 1 && skip < l->rbuf_valid_length);
+    pa_assert(l);
+    pa_assert(PA_REFCNT_VALUE(l) >= 1);
+    pa_assert(skip < l->rbuf_valid_length);
 
     while (!l->dead && l->rbuf_valid_length > skip) {
         char *e, *p;
@@ -255,7 +259,8 @@
 static int do_write(pa_ioline *l);
 
 static int do_read(pa_ioline *l) {
-    assert(l && l->ref >= 1);
+    pa_assert(l);
+    pa_assert(PA_REFCNT_VALUE(l) >= 1);
 
     while (!l->dead && pa_iochannel_is_readable(l->io)) {
         ssize_t r;
@@ -289,7 +294,7 @@
 
         len = l->rbuf_length - l->rbuf_index - l->rbuf_valid_length;
 
-        assert(len >= READ_SIZE);
+        pa_assert(len >= READ_SIZE);
 
         /* Read some data */
         if ((r = pa_iochannel_read(l->io, l->rbuf+l->rbuf_index+l->rbuf_valid_length, len)) <= 0) {
@@ -314,7 +319,9 @@
 /* Try to flush the buffer */
 static int do_write(pa_ioline *l) {
     ssize_t r;
-    assert(l && l->ref >= 1);
+
+    pa_assert(l);
+    pa_assert(PA_REFCNT_VALUE(l) >= 1);
 
     while (!l->dead && pa_iochannel_is_writable(l->io) && l->wbuf_valid_length) {
 
@@ -341,8 +348,8 @@
 
 /* Try to flush read/write data */
 static void do_work(pa_ioline *l) {
-    assert(l);
-    assert(l->ref >= 1);
+    pa_assert(l);
+    pa_assert(PA_REFCNT_VALUE(l) >= 1);
 
     pa_ioline_ref(l);
 
@@ -362,21 +369,28 @@
 
 static void io_callback(pa_iochannel*io, void *userdata) {
     pa_ioline *l = userdata;
-    assert(io && l && l->ref >= 1);
+    
+    pa_assert(io);
+    pa_assert(l);
+    pa_assert(PA_REFCNT_VALUE(l) >= 1);
 
     do_work(l);
 }
 
 static void defer_callback(pa_mainloop_api*m, pa_defer_event*e, void *userdata) {
     pa_ioline *l = userdata;
-    assert(l && l->ref >= 1 && l->mainloop == m && l->defer_event == e);
+
+    pa_assert(l);
+    pa_assert(PA_REFCNT_VALUE(l) >= 1);
+    pa_assert(l->mainloop == m);
+    pa_assert(l->defer_event == e);
 
     do_work(l);
 }
 
 void pa_ioline_defer_close(pa_ioline *l) {
-    assert(l);
-    assert(l->ref >= 1);
+    pa_assert(l);
+    pa_assert(PA_REFCNT_VALUE(l) >= 1);
 
     l->defer_close = 1;
 
@@ -388,8 +402,8 @@
     char *t;
     va_list ap;
 
-    assert(l);
-    assert(l->ref >= 1);
+    pa_assert(l);
+    pa_assert(PA_REFCNT_VALUE(l) >= 1);
 
     va_start(ap, format);
     t = pa_vsprintf_malloc(format, ap);

Modified: branches/lennart/src/pulsecore/ipacl.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/ipacl.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/ipacl.c (original)
+++ branches/lennart/src/pulsecore/ipacl.c Tue Sep 11 22:48:33 2007
@@ -46,13 +46,13 @@
 #include <arpa/inet.h>
 #endif
 
-#include "winsock.h"
-
 #include <pulse/xmalloc.h>
 
 #include <pulsecore/core-util.h>
 #include <pulsecore/llist.h>
 #include <pulsecore/log.h>
+#include <pulsecore/macro.h>
+#include <pulsecore/winsock.h>
 
 #ifndef HAVE_INET_PTON
 #include "inet_pton.h"
@@ -77,7 +77,7 @@
     char *a;
     pa_ip_acl *acl;
 
-    assert(s);
+    pa_assert(s);
 
     acl = pa_xnew(pa_ip_acl, 1);
     PA_LLIST_HEAD_INIT(struct acl_entry, acl->entries);
@@ -91,7 +91,7 @@
             *slash = 0;
             slash++;
             if (pa_atou(slash, &bits) < 0) {
-                pa_log("failed to parse number of bits: %s", slash);
+                pa_log_warn("Failed to parse number of bits: %s", slash);
                 goto fail;
             }
         } else
@@ -102,7 +102,7 @@
             e.bits = bits == (uint32_t) -1 ? 32 : (int) bits;
 
             if (e.bits > 32) {
-                pa_log("number of bits out of range: %i", e.bits);
+                pa_log_warn("Number of bits out of range: %i", e.bits);
                 goto fail;
             }
 
@@ -116,7 +116,7 @@
             e.bits = bits == (uint32_t) -1 ? 128 : (int) bits;
 
             if (e.bits > 128) {
-                pa_log("number of bits out of range: %i", e.bits);
+                pa_log_warn("Number of bits out of range: %i", e.bits);
                 goto fail;
             }
             e.family = AF_INET6;
@@ -142,7 +142,7 @@
             }
 
         } else {
-            pa_log("failed to parse address: %s", a);
+            pa_log_warn("Failed to parse address: %s", a);
             goto fail;
         }
 
@@ -162,7 +162,7 @@
 }
 
 void pa_ip_acl_free(pa_ip_acl *acl) {
-    assert(acl);
+    pa_assert(acl);
 
     while (acl->entries) {
         struct acl_entry *e = acl->entries;
@@ -178,8 +178,8 @@
     struct acl_entry *e;
     socklen_t  salen;
 
-    assert(acl);
-    assert(fd >= 0);
+    pa_assert(acl);
+    pa_assert(fd >= 0);
 
     salen = sizeof(sa);
     if (getpeername(fd, (struct sockaddr*) &sa, &salen) < 0)

Modified: branches/lennart/src/pulsecore/mcalign.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/mcalign.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/mcalign.c (original)
+++ branches/lennart/src/pulsecore/mcalign.c Tue Sep 11 22:48:33 2007
@@ -27,10 +27,10 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <assert.h>
 #include <string.h>
 
 #include <pulse/xmalloc.h>
+#include <pulsecore/macro.h>
 
 #include "mcalign.h"
 
@@ -41,7 +41,7 @@
 
 pa_mcalign *pa_mcalign_new(size_t base) {
     pa_mcalign *m;
-    assert(base);
+    pa_assert(base);
 
     m = pa_xnew(pa_mcalign, 1);
 
@@ -53,7 +53,7 @@
 }
 
 void pa_mcalign_free(pa_mcalign *m) {
-    assert(m);
+    pa_assert(m);
 
     if (m->leftover.memblock)
         pa_memblock_unref(m->leftover.memblock);
@@ -65,13 +65,13 @@
 }
 
 void pa_mcalign_push(pa_mcalign *m, const pa_memchunk *c) {
-    assert(m);
-    assert(c);
-
-    assert(c->memblock);
-    assert(c->length > 0);
-
-    assert(!m->current.memblock);
+    pa_assert(m);
+    pa_assert(c);
+
+    pa_assert(c->memblock);
+    pa_assert(c->length > 0);
+
+    pa_assert(!m->current.memblock);
 
     /* Append to the leftover memory block */
     if (m->leftover.memblock) {
@@ -94,7 +94,7 @@
             void *lo_data, *m_data;
 
             /* We have to copy */
-            assert(m->leftover.length < m->base);
+            pa_assert(m->leftover.length < m->base);
             l = m->base - m->leftover.length;
 
             if (l > c->length)
@@ -110,8 +110,8 @@
             pa_memblock_release(c->memblock);
             m->leftover.length += l;
 
-            assert(m->leftover.length <= m->base);
-            assert(m->leftover.length <= pa_memblock_get_length(m->leftover.memblock));
+            pa_assert(m->leftover.length <= m->base);
+            pa_assert(m->leftover.length <= pa_memblock_get_length(m->leftover.memblock));
 
             if (c->length > l) {
                 /* Save the remainder of the memory block */
@@ -134,12 +134,13 @@
 }
 
 int pa_mcalign_pop(pa_mcalign *m, pa_memchunk *c) {
-    assert(m);
-    assert(c);
+    pa_assert(m);
+    pa_assert(c);
 
     /* First test if there's a leftover memory block available */
     if (m->leftover.memblock) {
-        assert(m->leftover.length > 0 && m->leftover.length <= m->base);
+        pa_assert(m->leftover.length > 0);
+        pa_assert(m->leftover.length <= m->base);
 
         /* The leftover memory block is not yet complete */
         if (m->leftover.length < m->base)
@@ -161,13 +162,13 @@
     /* Now let's see if there is other data available */
     if (m->current.memblock) {
         size_t l;
-        assert(m->current.length >= m->base);
+        pa_assert(m->current.length >= m->base);
 
         /* The length of the returned memory block */
         l = m->current.length;
         l /= m->base;
         l *= m->base;
-        assert(l > 0);
+        pa_assert(l > 0);
 
         /* Prepare the returned block */
         *c = m->current;
@@ -175,7 +176,7 @@
         c->length = l;
 
         /* Drop that from the current memory block */
-        assert(l <= m->current.length);
+        pa_assert(l <= m->current.length);
         m->current.index += l;
         m->current.length -= l;
 
@@ -184,7 +185,7 @@
             pa_memblock_unref(m->current.memblock);
         else {
             /* Move the raimainder to leftover */
-            assert(m->current.length < m->base && !m->leftover.memblock);
+            pa_assert(m->current.length < m->base && !m->leftover.memblock);
 
             m->leftover = m->current;
         }
@@ -200,10 +201,10 @@
 }
 
 size_t pa_mcalign_csize(pa_mcalign *m, size_t l) {
-    assert(m);
-    assert(l > 0);
-
-    assert(!m->current.memblock);
+    pa_assert(m);
+    pa_assert(l > 0);
+
+    pa_assert(!m->current.memblock);
 
     if (m->leftover.memblock)
         l += m->leftover.length;

Modified: branches/lennart/src/pulsecore/memblock.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/memblock.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/memblock.c (original)
+++ branches/lennart/src/pulsecore/memblock.c Tue Sep 11 22:48:33 2007
@@ -28,7 +28,6 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <assert.h>
 #include <string.h>
 #include <unistd.h>
 #include <signal.h>

Modified: branches/lennart/src/pulsecore/memchunk.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/memchunk.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/memchunk.c (original)
+++ branches/lennart/src/pulsecore/memchunk.c Tue Sep 11 22:48:33 2007
@@ -27,7 +27,6 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <assert.h>
 #include <string.h>
 #include <errno.h>
 
@@ -42,8 +41,8 @@
     size_t l;
     void *tdata, *sdata;
 
-    assert(c);
-    assert(c->memblock);
+    pa_assert(c);
+    pa_assert(c->memblock);
 
     if (pa_memblock_ref_is_one(c->memblock) &&
         !pa_memblock_is_read_only(c->memblock) &&
@@ -68,7 +67,7 @@
 }
 
 pa_memchunk* pa_memchunk_reset(pa_memchunk *c) {
-    assert(c);
+    pa_assert(c);
 
     c->memblock = NULL;
     c->length = c->index = 0;

Modified: branches/lennart/src/pulsecore/modargs.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/modargs.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/modargs.c (original)
+++ branches/lennart/src/pulsecore/modargs.c Tue Sep 11 22:48:33 2007
@@ -26,7 +26,6 @@
 #endif
 
 #include <ctype.h>
-#include <assert.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -39,6 +38,7 @@
 #include <pulsecore/sink.h>
 #include <pulsecore/source.h>
 #include <pulsecore/core-util.h>
+#include <pulsecore/macro.h>
 
 #include "modargs.h"
 
@@ -48,7 +48,10 @@
 
 static int add_key_value(pa_hashmap *map, char *key, char *value, const char* const valid_keys[]) {
     struct entry *e;
-    assert(map && key && value);
+    
+    pa_assert(map);
+    pa_assert(key);
+    pa_assert(value);
 
     if (valid_keys) {
         const char*const* v;
@@ -63,10 +66,11 @@
         }
     }
 
-    e = pa_xmalloc(sizeof(struct entry));
+    e = pa_xnew(struct entry, 1);
     e->key = key;
     e->value = value;
     pa_hashmap_put(map, key, e);
+    
     return 0;
 }
 
@@ -74,7 +78,6 @@
     pa_hashmap *map = NULL;
 
     map = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
-    assert(map);
 
     if (args) {
         enum { WHITESPACE, KEY, VALUE_START, VALUE_SIMPLE, VALUE_DOUBLE_QUOTES, VALUE_TICKS } state;
@@ -166,10 +169,10 @@
     return NULL;
 }
 
-
 static void free_func(void *p, PA_GCC_UNUSED void*userdata) {
     struct entry *e = p;
-    assert(e);
+    pa_assert(e);
+    
     pa_xfree(e->key);
     pa_xfree(e->value);
     pa_xfree(e);
@@ -192,7 +195,10 @@
 
 int pa_modargs_get_value_u32(pa_modargs *ma, const char *key, uint32_t *value) {
     const char *v;
-    assert(ma && key && value);
+
+    pa_assert(ma);
+    pa_assert(key);
+    pa_assert(value);
 
     if (!(v = pa_modargs_get_value(ma, key, NULL)))
         return 0;
@@ -205,7 +211,10 @@
 
 int pa_modargs_get_value_s32(pa_modargs *ma, const char *key, int32_t *value) {
     const char *v;
-    assert(ma && key && value);
+
+    pa_assert(ma);
+    pa_assert(key);
+    pa_assert(value);
 
     if (!(v = pa_modargs_get_value(ma, key, NULL)))
         return 0;
@@ -219,7 +228,10 @@
 int pa_modargs_get_value_boolean(pa_modargs *ma, const char *key, int *value) {
     const char *v;
     int r;
-    assert(ma && key && value);
+
+    pa_assert(ma);
+    pa_assert(key);
+    pa_assert(value);
 
     if (!(v = pa_modargs_get_value(ma, key, NULL)))
         return 0;
@@ -238,9 +250,9 @@
     const char *format;
     uint32_t channels;
     pa_sample_spec ss;
-    assert(ma && rss);
-
-/*    DEBUG_TRAP;*/
+    
+    pa_assert(ma);
+    pa_assert(rss);
 
     ss = *rss;
     if ((pa_modargs_get_value_u32(ma, "rate", &ss.rate)) < 0)
@@ -267,8 +279,8 @@
     pa_channel_map map;
     const char *cm;
 
-    assert(ma);
-    assert(rmap);
+    pa_assert(ma);
+    pa_assert(rmap);
 
     map = *rmap;
 
@@ -287,9 +299,9 @@
     pa_sample_spec ss;
     pa_channel_map map;
 
-    assert(ma);
-    assert(rss);
-    assert(rmap);
+    pa_assert(ma);
+    pa_assert(rss);
+    pa_assert(rmap);
 
     ss = *rss;
 

Modified: branches/lennart/src/pulsecore/modinfo.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/modinfo.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/modinfo.c (original)
+++ branches/lennart/src/pulsecore/modinfo.c Tue Sep 11 22:48:33 2007
@@ -82,7 +82,7 @@
 }
 
 void pa_modinfo_free(pa_modinfo *i) {
-    assert(i);
+    pa_assert(i);
     
     pa_xfree(i->author);
     pa_xfree(i->description);

Modified: branches/lennart/src/pulsecore/module.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/module.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/module.c (original)
+++ branches/lennart/src/pulsecore/module.c Tue Sep 11 22:48:33 2007
@@ -157,7 +157,8 @@
 }
 
 void pa_module_unload(pa_core *c, pa_module *m) {
-    pa_assert(c && m);
+    pa_assert(c);
+    pa_assert(m);
 
     pa_assert(c->modules);
     if (!(m = pa_idxset_remove_by_data(c->modules, m, NULL)))

Modified: branches/lennart/src/pulsecore/mutex-posix.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/mutex-posix.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/mutex-posix.c (original)
+++ branches/lennart/src/pulsecore/mutex-posix.c Tue Sep 11 22:48:33 2007
@@ -25,17 +25,12 @@
 #include <config.h>
 #endif
 
-#include <assert.h>
 #include <pthread.h>
 
 #include <pulse/xmalloc.h>
+#include <pulsecore/macro.h>
 
 #include "mutex.h"
-
-#define ASSERT_SUCCESS(x) do { \
-    int _r = (x); \
-    assert(_r == 0); \
-} while(0)
 
 struct pa_mutex {
     pthread_mutex_t mutex;
@@ -52,61 +47,59 @@
     pthread_mutexattr_init(&attr);
 
     if (recursive)
-        ASSERT_SUCCESS(pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE));
+        pa_assert_se(pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE) == 0);
 
     m = pa_xnew(pa_mutex, 1);
-
-    ASSERT_SUCCESS(pthread_mutex_init(&m->mutex, &attr));
+    pa_assert_se(pthread_mutex_init(&m->mutex, &attr) == 0);
     return m;
 }
 
 void pa_mutex_free(pa_mutex *m) {
-    assert(m);
+    pa_assert(m);
 
-    ASSERT_SUCCESS(pthread_mutex_destroy(&m->mutex));
+    pa_assert_se(pthread_mutex_destroy(&m->mutex) == 0);
     pa_xfree(m);
 }
 
 void pa_mutex_lock(pa_mutex *m) {
-    assert(m);
+    pa_assert(m);
 
-    ASSERT_SUCCESS(pthread_mutex_lock(&m->mutex));
+    pa_assert_se(pthread_mutex_lock(&m->mutex) == 0);
 }
 
 void pa_mutex_unlock(pa_mutex *m) {
-    assert(m);
+    pa_assert(m);
 
-    ASSERT_SUCCESS(pthread_mutex_unlock(&m->mutex));
+    pa_assert_se(pthread_mutex_unlock(&m->mutex) == 0);
 }
 
 pa_cond *pa_cond_new(void) {
     pa_cond *c;
 
     c = pa_xnew(pa_cond, 1);
-
-    ASSERT_SUCCESS(pthread_cond_init(&c->cond, NULL));
+    pa_assert_se(pthread_cond_init(&c->cond, NULL) == 0);
     return c;
 }
 
 void pa_cond_free(pa_cond *c) {
-    assert(c);
+    pa_assert(c);
 
-    ASSERT_SUCCESS(pthread_cond_destroy(&c->cond));
+    pa_assert_se(pthread_cond_destroy(&c->cond) == 0);
     pa_xfree(c);
 }
 
 void pa_cond_signal(pa_cond *c, int broadcast) {
-    assert(c);
+    pa_assert(c);
 
     if (broadcast)
-        ASSERT_SUCCESS(pthread_cond_broadcast(&c->cond));
+        pa_assert_se(pthread_cond_broadcast(&c->cond) == 0);
     else
-        ASSERT_SUCCESS(pthread_cond_signal(&c->cond));
+        pa_assert_se(pthread_cond_signal(&c->cond) == 0);
 }
 
 int pa_cond_wait(pa_cond *c, pa_mutex *m) {
-    assert(c);
-    assert(m);
+    pa_assert(c);
+    pa_assert(m);
 
     return pthread_cond_wait(&c->cond, &m->mutex);
 }

Modified: branches/lennart/src/pulsecore/namereg.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/namereg.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/namereg.c (original)
+++ branches/lennart/src/pulsecore/namereg.c Tue Sep 11 22:48:33 2007
@@ -27,7 +27,6 @@
 
 #include <stdlib.h>
 #include <string.h>
-#include <assert.h>
 #include <string.h>
 #include <stdio.h>
 
@@ -38,6 +37,7 @@
 #include <pulsecore/sink.h>
 #include <pulsecore/core-subscribe.h>
 #include <pulsecore/core-util.h>
+#include <pulsecore/macro.h>
 
 #include "namereg.h"
 
@@ -90,23 +90,22 @@
 }
 
 void pa_namereg_free(pa_core *c) {
-    assert(c);
+    pa_assert(c);
 
     if (!c->namereg)
         return;
 
-    assert(pa_hashmap_size(c->namereg) == 0);
+    pa_assert(pa_hashmap_size(c->namereg) == 0);
     pa_hashmap_free(c->namereg, NULL, NULL);
 }
 
 const char *pa_namereg_register(pa_core *c, const char *name, pa_namereg_type_t type, void *data, int fail) {
     struct namereg_entry *e;
     char *n = NULL;
-    int r;
-
-    assert(c);
-    assert(name);
-    assert(data);
+
+    pa_assert(c);
+    pa_assert(name);
+    pa_assert(data);
 
     if (!*name)
         return NULL;
@@ -163,8 +162,7 @@
     e->name = n ? n : pa_xstrdup(name);
     e->data = data;
 
-    r = pa_hashmap_put(c->namereg, e->name, e);
-    assert (r >= 0);
+    pa_assert_se(pa_hashmap_put(c->namereg, e->name, e) >= 0);
 
     return e->name;
 }
@@ -172,11 +170,10 @@
 void pa_namereg_unregister(pa_core *c, const char *name) {
     struct namereg_entry *e;
 
-    assert(c);
-    assert(name);
-
-    e = pa_hashmap_remove(c->namereg, name);
-    assert(e);
+    pa_assert(c);
+    pa_assert(name);
+
+    pa_assert_se(e = pa_hashmap_remove(c->namereg, name));
 
     pa_xfree(e->name);
     pa_xfree(e);
@@ -185,7 +182,7 @@
 void* pa_namereg_get(pa_core *c, const char *name, pa_namereg_type_t type, int autoload) {
     struct namereg_entry *e;
     uint32_t idx;
-    assert(c);
+    pa_assert(c);
 
     if (!name) {
 
@@ -245,8 +242,8 @@
 int pa_namereg_set_default(pa_core*c, const char *name, pa_namereg_type_t type) {
     char **s;
 
-    assert(c);
-    assert(type == PA_NAMEREG_SINK || type == PA_NAMEREG_SOURCE);
+    pa_assert(c);
+    pa_assert(type == PA_NAMEREG_SINK || type == PA_NAMEREG_SOURCE);
 
     s = type == PA_NAMEREG_SINK ? &c->default_sink_name : &c->default_source_name;
 
@@ -269,7 +266,7 @@
 const char *pa_namereg_get_default_sink_name(pa_core *c) {
     pa_sink *s;
 
-    assert(c);
+    pa_assert(c);
 
     if (c->default_sink_name)
         return c->default_sink_name;
@@ -284,7 +281,7 @@
     pa_source *s;
     uint32_t idx;
 
-    assert(c);
+    pa_assert(c);
 
     if (c->default_source_name)
         return c->default_source_name;

Modified: branches/lennart/src/pulsecore/packet.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/packet.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/packet.c (original)
+++ branches/lennart/src/pulsecore/packet.c Tue Sep 11 22:48:33 2007
@@ -25,22 +25,22 @@
 #include <config.h>
 #endif
 
-#include <assert.h>
 #include <stdlib.h>
 
 #include <pulse/xmalloc.h>
+#include <pulsecore/macro.h>
 
 #include "packet.h"
 
 pa_packet* pa_packet_new(size_t length) {
     pa_packet *p;
 
-    assert(length);
+    pa_assert(length > 0);
 
-    p = pa_xmalloc(sizeof(pa_packet)+length);
-    p->ref = 1;
+    p = pa_xmalloc(PA_ALIGN(sizeof(pa_packet)) + length);
+    PA_REFCNT_INIT(p);
     p->length = length;
-    p->data = (uint8_t*) (p+1);
+    p->data = (uint8_t*) p + PA_ALIGN(sizeof(pa_packet));
     p->type = PA_PACKET_APPENDED;
 
     return p;
@@ -49,11 +49,11 @@
 pa_packet* pa_packet_new_dynamic(void* data, size_t length) {
     pa_packet *p;
 
-    assert(data);
-    assert(length);
+    pa_assert(data);
+    pa_assert(length > 0);
 
     p = pa_xnew(pa_packet, 1);
-    p->ref = 1;
+    PA_REFCNT_INIT(p);
     p->length = length;
     p->data = data;
     p->type = PA_PACKET_DYNAMIC;
@@ -62,18 +62,18 @@
 }
 
 pa_packet* pa_packet_ref(pa_packet *p) {
-    assert(p);
-    assert(p->ref >= 1);
+    pa_assert(p);
+    pa_assert(PA_REFCNT_VALUE(p) >= 1);
 
-    p->ref++;
+    PA_REFCNT_INC(p);
     return p;
 }
 
 void pa_packet_unref(pa_packet *p) {
-    assert(p);
-    assert(p->ref >= 1);
+    pa_assert(p);
+    pa_assert(PA_REFCNT_VALUE(p) >= 1);
 
-    if (--p->ref == 0) {
+    if (PA_REFCNT_DEC(p) <= 0) {
         if (p->type == PA_PACKET_DYNAMIC)
             pa_xfree(p->data);
         pa_xfree(p);

Modified: branches/lennart/src/pulsecore/packet.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/packet.h?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/packet.h (original)
+++ branches/lennart/src/pulsecore/packet.h Tue Sep 11 22:48:33 2007
@@ -27,9 +27,11 @@
 #include <sys/types.h>
 #include <inttypes.h>
 
+#include <pulsecore/refcnt.h>
+
 typedef struct pa_packet {
+    PA_REFCNT_DECLARE;
     enum { PA_PACKET_APPENDED, PA_PACKET_DYNAMIC } type;
-    unsigned ref;
     size_t length;
     uint8_t *data;
 } pa_packet;

Modified: branches/lennart/src/pulsecore/parseaddr.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/parseaddr.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/parseaddr.c (original)
+++ branches/lennart/src/pulsecore/parseaddr.c Tue Sep 11 22:48:33 2007
@@ -26,13 +26,13 @@
 #endif
 
 #include <string.h>
-#include <assert.h>
 #include <stdlib.h>
 
 #include <pulse/xmalloc.h>
+#include <pulse/util.h>
 
-#include <pulse/util.h>
 #include <pulsecore/core-util.h>
+#include <pulsecore/macro.h>
 
 #include "parseaddr.h"
 
@@ -45,7 +45,9 @@
  *  Return a newly allocated string of the hostname and fill in *ret_port if specified  */
 
 static char *parse_host(const char *s, uint16_t *ret_port) {
-    assert(s && ret_port);
+    pa_assert(s);
+    pa_assert(ret_port);
+    
     if (*s == '[') {
         char *e;
         if (!(e = strchr(s+1, ']')))
@@ -70,7 +72,10 @@
 
 int pa_parse_address(const char *name, pa_parsed_address *ret_p) {
     const char *p;
-    assert(name && ret_p);
+    
+    pa_assert(name);
+    pa_assert(ret_p);
+    
     memset(ret_p, 0, sizeof(pa_parsed_address));
     ret_p->type = PA_PARSED_ADDRESS_TCP_AUTO;
 
@@ -112,6 +117,5 @@
         if (!(ret_p->path_or_host = parse_host(p, &ret_p->port)))
             return -1;
 
-
     return 0;
 }

Modified: branches/lennart/src/pulsecore/pdispatch.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/pdispatch.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/pdispatch.c (original)
+++ branches/lennart/src/pulsecore/pdispatch.c Tue Sep 11 22:48:33 2007
@@ -28,7 +28,6 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <assert.h>
 
 #include <pulse/timeval.h>
 #include <pulse/xmalloc.h>
@@ -37,6 +36,8 @@
 #include <pulsecore/llist.h>
 #include <pulsecore/log.h>
 #include <pulsecore/core-util.h>
+#include <pulsecore/macro.h>
+#include <pulsecore/refcnt.h>
 
 #include "pdispatch.h"
 
@@ -108,7 +109,7 @@
 };
 
 struct pa_pdispatch {
-    int ref;
+    PA_REFCNT_DECLARE;
     pa_mainloop_api *mainloop;
     const pa_pdispatch_cb_t *callback_table;
     unsigned n_commands;
@@ -119,7 +120,9 @@
 };
 
 static void reply_info_free(struct reply_info *r) {
-    assert(r && r->pdispatch && r->pdispatch->mainloop);
+    pa_assert(r);
+    pa_assert(r->pdispatch);
+    pa_assert(r->pdispatch->mainloop);
 
     if (r->time_event)
         r->pdispatch->mainloop->time_free(r->time_event);
@@ -131,12 +134,12 @@
 
 pa_pdispatch* pa_pdispatch_new(pa_mainloop_api *mainloop, const pa_pdispatch_cb_t*table, unsigned entries) {
     pa_pdispatch *pd;
-    assert(mainloop);
-
-    assert((entries && table) || (!entries && !table));
-
-    pd = pa_xmalloc(sizeof(pa_pdispatch));
-    pd->ref = 1;
+    pa_assert(mainloop);
+
+    pa_assert((entries && table) || (!entries && !table));
+
+    pd = pa_xnew(pa_pdispatch, 1);
+    PA_REFCNT_INIT(pd);
     pd->mainloop = mainloop;
     pd->callback_table = table;
     pd->n_commands = entries;
@@ -149,7 +152,7 @@
 }
 
 static void pdispatch_free(pa_pdispatch *pd) {
-    assert(pd);
+    pa_assert(pd);
 
     while (pd->replies) {
         if (pd->replies->free_cb)
@@ -165,7 +168,7 @@
     pa_pdispatch_cb_t callback;
     void *userdata;
     uint32_t tag;
-    assert(r);
+    pa_assert(r);
 
     pa_pdispatch_ref(pd);
 
@@ -187,7 +190,12 @@
     uint32_t tag, command;
     pa_tagstruct *ts = NULL;
     int ret = -1;
-    assert(pd && packet && packet->data);
+    
+    pa_assert(pd);
+    pa_assert(PA_REFCNT_VALUE(pd) >= 1);
+    pa_assert(packet);
+    pa_assert(PA_REFCNT_VALUE(packet) >= 1);
+    pa_assert(packet->data);
 
     pa_pdispatch_ref(pd);
 
@@ -195,7 +203,6 @@
         goto finish;
 
     ts = pa_tagstruct_new(packet->data, packet->length);
-    assert(ts);
 
     if (pa_tagstruct_getu32(ts, &command) < 0 ||
         pa_tagstruct_getu32(ts, &tag) < 0)
@@ -248,7 +255,12 @@
 
 static void timeout_callback(pa_mainloop_api*m, pa_time_event*e, PA_GCC_UNUSED const struct timeval *tv, void *userdata) {
     struct reply_info*r = userdata;
-    assert(r && r->time_event == e && r->pdispatch && r->pdispatch->mainloop == m && r->callback);
+    
+    pa_assert(r);
+    pa_assert(r->time_event == e);
+    pa_assert(r->pdispatch);
+    pa_assert(r->pdispatch->mainloop == m);
+    pa_assert(r->callback);
 
     run_action(r->pdispatch, r, PA_COMMAND_TIMEOUT, NULL);
 }
@@ -256,7 +268,10 @@
 void pa_pdispatch_register_reply(pa_pdispatch *pd, uint32_t tag, int timeout, pa_pdispatch_cb_t cb, void *userdata, pa_free_cb_t free_cb) {
     struct reply_info *r;
     struct timeval tv;
-    assert(pd && pd->ref >= 1 && cb);
+    
+    pa_assert(pd);
+    pa_assert(PA_REFCNT_VALUE(pd) >= 1);
+    pa_assert(cb);
 
     r = pa_xnew(struct reply_info, 1);
     r->pdispatch = pd;
@@ -268,21 +283,22 @@
     pa_gettimeofday(&tv);
     tv.tv_sec += timeout;
 
-    r->time_event = pd->mainloop->time_new(pd->mainloop, &tv, timeout_callback, r);
-    assert(r->time_event);
+    pa_assert_se(r->time_event = pd->mainloop->time_new(pd->mainloop, &tv, timeout_callback, r));
 
     PA_LLIST_PREPEND(struct reply_info, pd->replies, r);
 }
 
 int pa_pdispatch_is_pending(pa_pdispatch *pd) {
-    assert(pd);
+    pa_assert(pd);
+    pa_assert(PA_REFCNT_VALUE(pd) >= 1);
 
     return !!pd->replies;
 }
 
 void pa_pdispatch_set_drain_callback(pa_pdispatch *pd, void (*cb)(pa_pdispatch *pd, void *userdata), void *userdata) {
-    assert(pd);
-    assert(!cb || pa_pdispatch_is_pending(pd));
+    pa_assert(pd);
+    pa_assert(PA_REFCNT_VALUE(pd) >= 1);
+    pa_assert(!cb || pa_pdispatch_is_pending(pd));
 
     pd->drain_callback = cb;
     pd->drain_userdata = userdata;
@@ -290,7 +306,9 @@
 
 void pa_pdispatch_unregister_reply(pa_pdispatch *pd, void *userdata) {
     struct reply_info *r, *n;
-    assert(pd);
+
+    pa_assert(pd);
+    pa_assert(PA_REFCNT_VALUE(pd) >= 1);
 
     for (r = pd->replies; r; r = n) {
         n = r->next;
@@ -301,21 +319,24 @@
 }
 
 void pa_pdispatch_unref(pa_pdispatch *pd) {
-    assert(pd && pd->ref >= 1);
-
-    if (!(--(pd->ref)))
+    pa_assert(pd);
+    pa_assert(PA_REFCNT_VALUE(pd) >= 1);
+
+    if (PA_REFCNT_DEC(pd) <= 0)
         pdispatch_free(pd);
 }
 
 pa_pdispatch* pa_pdispatch_ref(pa_pdispatch *pd) {
-    assert(pd && pd->ref >= 1);
-    pd->ref++;
+    pa_assert(pd);
+    pa_assert(PA_REFCNT_VALUE(pd) >= 1);
+
+    PA_REFCNT_INC(pd);
     return pd;
 }
 
 const pa_creds * pa_pdispatch_creds(pa_pdispatch *pd) {
-    assert(pd);
-    assert(pd->ref >= 1);
+    pa_assert(pd);
+    pa_assert(PA_REFCNT_VALUE(pd) >= 1);
 
     return pd->creds;
 }

Modified: branches/lennart/src/pulsecore/pid.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/pid.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/pid.c (original)
+++ branches/lennart/src/pulsecore/pid.c Tue Sep 11 22:48:33 2007
@@ -33,7 +33,6 @@
 #include <sys/stat.h>
 #include <string.h>
 #include <stdio.h>
-#include <assert.h>
 #include <stdlib.h>
 #include <limits.h>
 #include <signal.h>
@@ -47,6 +46,7 @@
 #include <pulsecore/core-error.h>
 #include <pulsecore/core-util.h>
 #include <pulsecore/log.h>
+#include <pulsecore/macro.h>
 
 #include "pid.h"
 
@@ -57,7 +57,8 @@
     char t[20], *e;
     uint32_t pid;
 
-    assert(fn && fd >= 0);
+    pa_assert(fn);
+    pa_assert(fd >= 0);
 
     if ((r = pa_loop_read(fd, t, sizeof(t)-1, NULL)) < 0) {
         pa_log_warn("WARNING: failed to read PID file '%s': %s",
@@ -73,7 +74,7 @@
         *e = 0;
 
     if (pa_atou(t, &pid) < 0) {
-        pa_log("WARNING: failed to parse PID file '%s'", fn);
+        pa_log_warn("WARNING: failed to parse PID file '%s'", fn);
         return (pid_t) -1;
     }
 
@@ -82,6 +83,8 @@
 
 static int open_pid_file(const char *fn, int mode) {
     int fd = -1;
+
+    pa_assert(fn);
 
     for (;;) {
         struct stat st;
@@ -238,7 +241,7 @@
 
     if (fd >= 0) {
         pa_lock_fd(fd, 0);
-        close(fd);
+        pa_assert_se(close(fd) == 0);
     }
 
     return ret;
@@ -280,7 +283,7 @@
 
     if (fd >= 0) {
         pa_lock_fd(fd, 0);
-        close(fd);
+        pa_assert_se(close(fd) == 0);
     }
 
     return ret;

Modified: branches/lennart/src/pulsecore/props.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/props.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/props.c (original)
+++ branches/lennart/src/pulsecore/props.c Tue Sep 11 22:48:33 2007
@@ -25,11 +25,9 @@
 #include <config.h>
 #endif
 
-#include <assert.h>
-
 #include <pulse/xmalloc.h>
-
 #include <pulsecore/log.h>
+#include <pulsecore/macro.h>
 
 #include "props.h"
 
@@ -41,9 +39,11 @@
 /* Allocate a new property object */
 static pa_property* property_new(const char *name, void *data) {
     pa_property* p;
-    assert(name && data);
+    
+    pa_assert(name);
+    pa_assert(data);
 
-    p = pa_xmalloc(sizeof(pa_property));
+    p = pa_xnew(pa_property, 1);
     p->name = pa_xstrdup(name);
     p->data = data;
 
@@ -52,7 +52,7 @@
 
 /* Free a property object */
 static void property_free(pa_property *p) {
-    assert(p);
+    pa_assert(p);
 
     pa_xfree(p->name);
     pa_xfree(p);
@@ -60,7 +60,10 @@
 
 void* pa_property_get(pa_core *c, const char *name) {
     pa_property *p;
-    assert(c && name && c->properties);
+    
+    pa_assert(c);
+    pa_assert(name);
+    pa_assert(c->properties);
 
     if (!(p = pa_hashmap_get(c->properties, name)))
         return NULL;
@@ -70,7 +73,11 @@
 
 int pa_property_set(pa_core *c, const char *name, void *data) {
     pa_property *p;
-    assert(c && name && data && c->properties);
+    
+    pa_assert(c);
+    pa_assert(name);
+    pa_assert(data);
+    pa_assert(c->properties);
 
     if (pa_hashmap_get(c->properties, name))
         return -1;
@@ -82,7 +89,10 @@
 
 int pa_property_remove(pa_core *c, const char *name) {
     pa_property *p;
-    assert(c && name && c->properties);
+    
+    pa_assert(c);
+    pa_assert(name);
+    pa_assert(c->properties);
 
     if (!(p = pa_hashmap_remove(c->properties, name)))
         return -1;
@@ -92,18 +102,18 @@
 }
 
 void pa_property_init(pa_core *c) {
-    assert(c);
+    pa_assert(c);
 
     c->properties = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
 }
 
 void pa_property_cleanup(pa_core *c) {
-    assert(c);
+    pa_assert(c);
 
     if (!c->properties)
         return;
 
-    assert(!pa_hashmap_size(c->properties));
+    pa_assert(!pa_hashmap_size(c->properties));
 
     pa_hashmap_free(c->properties, NULL, NULL);
     c->properties = NULL;
@@ -113,14 +123,17 @@
 void pa_property_dump(pa_core *c, pa_strbuf *s) {
     void *state = NULL;
     pa_property *p;
-    assert(c && s);
+    
+    pa_assert(c);
+    pa_assert(s);
 
     while ((p = pa_hashmap_iterate(c->properties, &state, NULL)))
         pa_strbuf_printf(s, "[%s] -> [%p]\n", p->name, p->data);
 }
 
 int pa_property_replace(pa_core *c, const char *name, void *data) {
-    assert(c && name);
+    pa_assert(c);
+    pa_assert(name);
 
     pa_property_remove(c, name);
     return pa_property_set(c, name, data);

Modified: branches/lennart/src/pulsecore/protocol-cli.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/protocol-cli.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/protocol-cli.c (original)
+++ branches/lennart/src/pulsecore/protocol-cli.c Tue Sep 11 22:48:33 2007
@@ -25,13 +25,13 @@
 #include <config.h>
 #endif
 
-#include <assert.h>
 #include <stdlib.h>
 
 #include <pulse/xmalloc.h>
 
 #include <pulsecore/cli.h>
 #include <pulsecore/log.h>
+#include <pulsecore/macro.h>
 
 #include "protocol-cli.h"
 
@@ -47,7 +47,8 @@
 
 static void cli_eof_cb(pa_cli*c, void*userdata) {
     pa_protocol_cli *p = userdata;
-    assert(p);
+    pa_assert(p);
+    
     pa_idxset_remove_by_data(p->connections, c, NULL);
     pa_cli_free(c);
 }
@@ -55,7 +56,10 @@
 static void on_connection(pa_socket_server*s, pa_iochannel *io, void *userdata) {
     pa_protocol_cli *p = userdata;
     pa_cli *c;
-    assert(s && io && p);
+    
+    pa_assert(s);
+    pa_assert(io);
+    pa_assert(p);
 
     if (pa_idxset_size(p->connections)+1 > MAX_CONNECTIONS) {
         pa_log("Warning! Too many connections (%u), dropping incoming connection.", MAX_CONNECTIONS);
@@ -64,7 +68,6 @@
     }
 
     c = pa_cli_new(p->core, io, p->module);
-    assert(c);
     pa_cli_set_eof_callback(c, cli_eof_cb, p);
 
     pa_idxset_put(p->connections, c, NULL);
@@ -72,9 +75,11 @@
 
 pa_protocol_cli* pa_protocol_cli_new(pa_core *core, pa_socket_server *server, pa_module *m, PA_GCC_UNUSED pa_modargs *ma) {
     pa_protocol_cli* p;
-    assert(core && server);
 
-    p = pa_xmalloc(sizeof(pa_protocol_cli));
+    pa_core_assert_ref(core);
+    pa_assert(server);
+
+    p = pa_xnew(pa_protocol_cli, 1);
     p->module = m;
     p->core = core;
     p->server = server;
@@ -86,12 +91,13 @@
 }
 
 static void free_connection(void *p, PA_GCC_UNUSED void *userdata) {
-    assert(p);
+    pa_assert(p);
+    
     pa_cli_free(p);
 }
 
 void pa_protocol_cli_free(pa_protocol_cli *p) {
-    assert(p);
+    pa_assert(p);
 
     pa_idxset_free(p->connections, free_connection, NULL);
     pa_socket_server_unref(p->server);

Modified: branches/lennart/src/pulsecore/protocol-http.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/protocol-http.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/protocol-http.c (original)
+++ branches/lennart/src/pulsecore/protocol-http.c Tue Sep 11 22:48:33 2007
@@ -25,7 +25,6 @@
 #include <config.h>
 #endif
 
-#include <assert.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -34,6 +33,7 @@
 #include <pulse/xmalloc.h>
 
 #include <pulsecore/ioline.h>
+#include <pulsecore/macro.h>
 #include <pulsecore/log.h>
 #include <pulsecore/namereg.h>
 #include <pulsecore/cli-text.h>
@@ -65,9 +65,10 @@
 
 static void http_response(struct connection *c, int code, const char *msg, const char *mime) {
     char s[256];
-    assert(c);
-    assert(msg);
-    assert(mime);
+    
+    pa_assert(c);
+    pa_assert(msg);
+    pa_assert(mime);
 
     pa_snprintf(s, sizeof(s),
              "HTTP/1.0 %i %s\n"
@@ -83,7 +84,7 @@
 
 static void http_message(struct connection *c, int code, const char *msg, const char *text) {
     char s[256];
-    assert(c);
+    pa_assert(c);
 
     http_response(c, code, msg, "text/html");
 
@@ -103,21 +104,22 @@
 
 
 static void connection_free(struct connection *c, int del) {
-    assert(c);
+    pa_assert(c);
 
     if (c->url)
         pa_xfree(c->url);
 
     if (del)
         pa_idxset_remove_by_data(c->protocol->connections, c, NULL);
+    
     pa_ioline_unref(c->line);
     pa_xfree(c);
 }
 
 static void line_callback(pa_ioline *line, const char *s, void *userdata) {
     struct connection *c = userdata;
-    assert(line);
-    assert(c);
+    pa_assert(line);
+    pa_assert(c);
 
     if (!s) {
         /* EOF */
@@ -223,7 +225,10 @@
 static void on_connection(pa_socket_server*s, pa_iochannel *io, void *userdata) {
     pa_protocol_http *p = userdata;
     struct connection *c;
-    assert(s && io && p);
+    
+    pa_assert(s);
+    pa_assert(io);
+    pa_assert(p);
 
     if (pa_idxset_size(p->connections)+1 > MAX_CONNECTIONS) {
         pa_log_warn("Warning! Too many connections (%u), dropping incoming connection.", MAX_CONNECTIONS);
@@ -231,7 +236,7 @@
         return;
     }
 
-    c = pa_xmalloc(sizeof(struct connection));
+    c = pa_xnew(struct connection, 1);
     c->protocol = p;
     c->line = pa_ioline_new(io);
     c->state = REQUEST_LINE;
@@ -243,9 +248,11 @@
 
 pa_protocol_http* pa_protocol_http_new(pa_core *core, pa_socket_server *server, pa_module *m, PA_GCC_UNUSED pa_modargs *ma) {
     pa_protocol_http* p;
-    assert(core && server);
-
-    p = pa_xmalloc(sizeof(pa_protocol_http));
+    
+    pa_core_assert_ref(core);
+    pa_assert(server);
+
+    p = pa_xnew(pa_protocol_http, 1);
     p->module = m;
     p->core = core;
     p->server = server;
@@ -257,12 +264,12 @@
 }
 
 static void free_connection(void *p, PA_GCC_UNUSED void *userdata) {
-    assert(p);
+    pa_assert(p);
     connection_free(p, 0);
 }
 
 void pa_protocol_http_free(pa_protocol_http *p) {
-    assert(p);
+    pa_assert(p);
 
     pa_idxset_free(p->connections, free_connection, NULL);
     pa_socket_server_unref(p->server);

Modified: branches/lennart/src/pulsecore/pstream-util.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/pstream-util.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/pstream-util.c (original)
+++ branches/lennart/src/pulsecore/pstream-util.c Tue Sep 11 22:48:33 2007
@@ -25,9 +25,8 @@
 #include <config.h>
 #endif
 
-#include <assert.h>
-
 #include <pulsecore/native-common.h>
+#include <pulsecore/macro.h>
 
 #include "pstream-util.h"
 
@@ -35,20 +34,20 @@
     size_t length;
     uint8_t *data;
     pa_packet *packet;
-    assert(p);
-    assert(t);
 
-    data = pa_tagstruct_free_data(t, &length);
-    assert(data && length);
-    packet = pa_packet_new_dynamic(data, length);
-    assert(packet);
+    pa_assert(p);
+    pa_assert(t);
+
+    pa_assert_se(data = pa_tagstruct_free_data(t, &length));
+    pa_assert_se(packet = pa_packet_new_dynamic(data, length));
     pa_pstream_send_packet(p, packet, creds);
     pa_packet_unref(packet);
 }
 
 void pa_pstream_send_error(pa_pstream *p, uint32_t tag, uint32_t error) {
-    pa_tagstruct *t = pa_tagstruct_new(NULL, 0);
-    assert(t);
+    pa_tagstruct *t;
+
+    pa_assert_se(t = pa_tagstruct_new(NULL, 0));
     pa_tagstruct_putu32(t, PA_COMMAND_ERROR);
     pa_tagstruct_putu32(t, tag);
     pa_tagstruct_putu32(t, error);
@@ -56,8 +55,9 @@
 }
 
 void pa_pstream_send_simple_ack(pa_pstream *p, uint32_t tag) {
-    pa_tagstruct *t = pa_tagstruct_new(NULL, 0);
-    assert(t);
+    pa_tagstruct *t;
+    
+    pa_assert_se(t = pa_tagstruct_new(NULL, 0));
     pa_tagstruct_putu32(t, PA_COMMAND_REPLY);
     pa_tagstruct_putu32(t, tag);
     pa_pstream_send_tagstruct(p, t);

Modified: branches/lennart/src/pulsecore/queue.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/queue.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/queue.c (original)
+++ branches/lennart/src/pulsecore/queue.c Tue Sep 11 22:48:33 2007
@@ -72,6 +72,9 @@
 void pa_queue_push(pa_queue *q, void *p) {
     struct queue_entry *e;
 
+    pa_assert(q);
+    pa_assert(p);
+    
     if (!(e = pa_flist_pop(PA_STATIC_FLIST_GET(entries))))
         e = pa_xnew(struct queue_entry, 1);
     

Modified: branches/lennart/src/pulsecore/random.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/random.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/random.c (original)
+++ branches/lennart/src/pulsecore/random.c Tue Sep 11 22:48:33 2007
@@ -31,21 +31,22 @@
 #include <errno.h>
 #include <string.h>
 #include <stdlib.h>
-#include <assert.h>
 #include <time.h>
 
 #include <pulsecore/core-util.h>
 #include <pulsecore/log.h>
+#include <pulsecore/macro.h>
 
 #include "random.h"
 
 static int has_whined = 0;
 
-static const char *devices[] = { "/dev/urandom", "/dev/random", NULL };
+static const char * const devices[] = { "/dev/urandom", "/dev/random", NULL };
 
 static int random_proper(void *ret_data, size_t length) {
 #ifdef OS_IS_WIN32
-    assert(ret_data && length);
+    pa_assert(ret_data);
+    pa_assert(length > 0);
 
     return -1;
 
@@ -53,9 +54,10 @@
 
     int fd, ret = -1;
     ssize_t r = 0;
-    const char **device;
+    const char *const * device;
 
-    assert(ret_data && length);
+    pa_assert(ret_data);
+    pa_assert(length > 0);
 
     device = devices;
 
@@ -84,7 +86,7 @@
 
     if (random_proper(&seed, sizeof(unsigned int)) < 0) {
         if (!has_whined)
-            pa_log_warn("failed to get proper entropy. Falling back to seeding with current time.");
+            pa_log_warn("Failed to get proper entropy. Falling back to seeding with current time.");
         has_whined = 1;
 
         seed = (unsigned int) time(NULL);
@@ -97,13 +99,14 @@
     uint8_t *p;
     size_t l;
 
-    assert(ret_data && length);
+    pa_assert(ret_data);
+    pa_assert(length > 0);
 
     if (random_proper(ret_data, length) >= 0)
         return;
 
     if (!has_whined)
-        pa_log_warn("failed to get proper entropy. Falling back to unsecure pseudo RNG.");
+        pa_log_warn("Failed to get proper entropy. Falling back to unsecure pseudo RNG.");
     has_whined = 1;
 
     for (p = ret_data, l = length; l > 0; p++, l--)

Modified: branches/lennart/src/pulsecore/shm.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/shm.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/shm.c (original)
+++ branches/lennart/src/pulsecore/shm.c Tue Sep 11 22:48:33 2007
@@ -1,32 +1,31 @@
 /* $Id$ */
 
 /***
-  This file is part of PulseAudio.
-
-  Copyright 2006 Lennart Poettering
-  Copyright 2006 Pierre Ossman <ossman at cendio.se> for Cendio AB
-
-  PulseAudio 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.1 of the
-  License, or (at your option) any later version.
-
-  PulseAudio 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
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public
-  License along with PulseAudio; if not, write to the Free Software
-  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-  USA.
+    This file is part of PulseAudio.
+
+    Copyright 2006 Lennart Poettering
+    Copyright 2006 Pierre Ossman <ossman at cendio.se> for Cendio AB
+
+    PulseAudio 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.1 of the
+    License, or (at your option) any later version.
+
+    PulseAudio 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
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with PulseAudio; 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 <assert.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <fcntl.h>
@@ -63,10 +62,10 @@
     char fn[32];
     int fd = -1;
 
-    assert(m);
-    assert(size > 0);
-    assert(size < MAX_SHM_SIZE);
-    assert(mode >= 0600);
+    pa_assert(m);
+    pa_assert(size > 0);
+    pa_assert(size < MAX_SHM_SIZE);
+    pa_assert(mode >= 0600);
 
     if (!shared) {
         m->id = 0;
@@ -115,7 +114,7 @@
         close(fd);
         m->do_unlink = 1;
 #else
-                return -1;
+        return -1;
 #endif
     }
 
@@ -128,7 +127,7 @@
 #ifdef HAVE_SHM_OPEN
     if (fd >= 0) {
         shm_unlink(fn);
-        close(fd);
+        pa_assert_se(close(fd) >= 0);
     }
 #endif
 
@@ -136,12 +135,12 @@
 }
 
 void pa_shm_free(pa_shm *m) {
-    assert(m);
-    assert(m->ptr);
-    assert(m->size > 0);
+    pa_assert(m);
+    pa_assert(m->ptr);
+    pa_assert(m->size > 0);
 
 #ifdef MAP_FAILED
-    assert(m->ptr != MAP_FAILED);
+    pa_assert(m->ptr != MAP_FAILED);
 #endif
     
     if (!m->shared) {
@@ -179,13 +178,13 @@
     void *ptr;
     size_t o, ps;
 
-    assert(m);
-    assert(m->ptr);
-    assert(m->size > 0);
-    assert(offset+size <= m->size);
+    pa_assert(m);
+    pa_assert(m->ptr);
+    pa_assert(m->size > 0);
+    pa_assert(offset+size <= m->size);
 
 #ifdef MAP_FAILED
-    assert(m->ptr != MAP_FAILED);
+    pa_assert(m->ptr != MAP_FAILED);
 #endif
 
     /* You're welcome to implement this as NOOP on systems that don't
@@ -225,7 +224,7 @@
     int fd = -1;
     struct stat st;
 
-    assert(m);
+    pa_assert(m);
 
     segment_name(fn, sizeof(fn), m->id = id);
 
@@ -254,13 +253,13 @@
     m->do_unlink = 0;
     m->shared = 1;
 
-    close(fd);
+    pa_assert_se(close(fd) >= 0);
 
     return 0;
 
 fail:
     if (fd >= 0)
-        close(fd);
+        pa_assert_se(close(fd) >= 0);
 
     return -1;
 }
@@ -268,7 +267,7 @@
 #else /* HAVE_SHM_OPEN */
 
 int pa_shm_attach_ro(pa_shm *m, unsigned id) {
-        return -1;
+    return -1;
 }
 
 #endif /* HAVE_SHM_OPEN */

Modified: branches/lennart/src/pulsecore/sink.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/sink.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/sink.c (original)
+++ branches/lennart/src/pulsecore/sink.c Tue Sep 11 22:48:33 2007
@@ -27,7 +27,6 @@
 #endif
 
 #include <stdlib.h>
-#include <assert.h>
 #include <string.h>
 #include <stdio.h>
 
@@ -64,7 +63,6 @@
     pa_sink *s;
     char *n = NULL;
     char st[256];
-    int r;
     pa_channel_map tmap;
 
     pa_assert(core);
@@ -120,8 +118,7 @@
     s->rtpoll = NULL;
     s->silence = NULL;
 
-    r = pa_idxset_put(core->sinks, s, &s->index);
-    pa_assert(s->index != PA_IDXSET_INVALID && r >= 0);
+    pa_assert_se(pa_idxset_put(core->sinks, s, &s->index) >= 0);
 
     pa_sample_spec_snprint(st, sizeof(st), spec);
     pa_log_info("Created sink %u \"%s\" with sample spec \"%s\"", s->index, s->name, st);

Modified: branches/lennart/src/pulsecore/sioman.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/sioman.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/sioman.c (original)
+++ branches/lennart/src/pulsecore/sioman.c Tue Sep 11 22:48:33 2007
@@ -25,21 +25,17 @@
 #include <config.h>
 #endif
 
-#include <assert.h>
+#include <pulsecore/macro.h>
+#include <pulsecore/atomic.h>
 
 #include "sioman.h"
 
-static int stdio_inuse = 0;
+static pa_atomic_t stdio_inuse = PA_ATOMIC_INIT(0);
 
 int pa_stdio_acquire(void) {
-    if (stdio_inuse)
-        return -1;
-
-    stdio_inuse = 1;
-    return 0;
+    return pa_atomic_cmpxchg(&stdio_inuse, 0, 1) ? 0 : -1;
 }
 
 void pa_stdio_release(void) {
-    assert(stdio_inuse);
-    stdio_inuse = 0;
+    pa_assert_se(pa_atomic_cmpxchg(&stdio_inuse, 1, 0));
 }

Modified: branches/lennart/src/pulsecore/socket-client.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/socket-client.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/socket-client.c (original)
+++ branches/lennart/src/pulsecore/socket-client.c Tue Sep 11 22:48:33 2007
@@ -1,25 +1,25 @@
 /* $Id$ */
 
 /***
-  This file is part of PulseAudio.
-
-  Copyright 2004-2006 Lennart Poettering
-  Copyright 2006-2007 Pierre Ossman <ossman at cendio.se> for Cendio AB
-
-  PulseAudio 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.1 of the
-  License, or (at your option) any later version.
-
-  PulseAudio 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
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public
-  License along with PulseAudio; if not, write to the Free Software
-  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-  USA.
+    This file is part of PulseAudio.
+
+    Copyright 2004-2006 Lennart Poettering
+    Copyright 2006-2007 Pierre Ossman <ossman at cendio.se> for Cendio AB
+
+    PulseAudio 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.1 of the
+    License, or (at your option) any later version.
+
+    PulseAudio 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
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with PulseAudio; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+    USA.
 ***/
 
 #ifdef HAVE_CONFIG_H
@@ -32,7 +32,6 @@
 #include <stdio.h>
 #include <errno.h>
 #include <string.h>
-#include <assert.h>
 #include <stdlib.h>
 
 #ifdef HAVE_SYS_SOCKET_H
@@ -55,23 +54,24 @@
 #include <asyncns.h>
 #endif
 
-#include "winsock.h"
-
 #include <pulse/timeval.h>
 #include <pulse/xmalloc.h>
 
+#include <pulsecore/winsock.h>
 #include <pulsecore/core-error.h>
 #include <pulsecore/socket-util.h>
 #include <pulsecore/core-util.h>
 #include <pulsecore/log.h>
 #include <pulsecore/parseaddr.h>
+#include <pulsecore/macro.h>
+#include <pulsecore/refcnt.h>
 
 #include "socket-client.h"
 
 #define CONNECT_TIMEOUT 5
 
 struct pa_socket_client {
-    int ref;
+    PA_REFCNT_DECLARE;
     pa_mainloop_api *mainloop;
     int fd;
     pa_io_event *io_event;
@@ -89,10 +89,10 @@
 
 static pa_socket_client*pa_socket_client_new(pa_mainloop_api *m) {
     pa_socket_client *c;
-    assert(m);
-
-    c = pa_xmalloc(sizeof(pa_socket_client));
-    c->ref = 1;
+    pa_assert(m);
+
+    c = pa_xnew(pa_socket_client, 1);
+    PA_REFCNT_INIT(c);
     c->mainloop = m;
     c->fd = -1;
     c->io_event = NULL;
@@ -112,7 +112,7 @@
 }
 
 static void free_events(pa_socket_client *c) {
-    assert(c);
+    pa_assert(c);
 
     if (c->io_event) {
         c->mainloop->io_free(c->io_event);
@@ -134,7 +134,10 @@
     pa_iochannel *io = NULL;
     int error;
     socklen_t lerror;
-    assert(c && c->callback);
+    
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+    pa_assert(c->callback);
 
     pa_socket_client_ref(c);
 
@@ -159,7 +162,7 @@
     }
 
     io = pa_iochannel_new(c->mainloop, c->fd, c->fd);
-    assert(io);
+    pa_assert(io);
 
 finish:
     if (!io && c->fd >= 0)
@@ -168,7 +171,7 @@
 
     free_events(c);
 
-    assert(c->callback);
+    pa_assert(c->callback);
     c->callback(c, io, c->userdata);
 
     pa_socket_client_unref(c);
@@ -176,19 +179,34 @@
 
 static void connect_fixed_cb(pa_mainloop_api *m, pa_defer_event *e, void *userdata) {
     pa_socket_client *c = userdata;
-    assert(m && c && c->defer_event == e);
+    
+    pa_assert(m);
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+    pa_assert(c->defer_event == e);
+
     do_call(c);
 }
 
 static void connect_io_cb(pa_mainloop_api*m, pa_io_event *e, int fd, PA_GCC_UNUSED pa_io_event_flags_t f, void *userdata) {
     pa_socket_client *c = userdata;
-    assert(m && c && c->io_event == e && fd >= 0);
+
+    pa_assert(m);
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+    pa_assert(c->io_event == e);
+    pa_assert(fd >= 0);
+    
     do_call(c);
 }
 
 static int do_connect(pa_socket_client *c, const struct sockaddr *sa, socklen_t len) {
     int r;
-    assert(c && sa && len);
+    
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+    pa_assert(sa);
+    pa_assert(len > 0);
 
     pa_make_nonblock_fd(c->fd);
 
@@ -203,25 +221,24 @@
             return -1;
         }
 
-        c->io_event = c->mainloop->io_new(c->mainloop, c->fd, PA_IO_EVENT_OUTPUT, connect_io_cb, c);
-        assert(c->io_event);
-    } else {
-        c->defer_event = c->mainloop->defer_new(c->mainloop, connect_fixed_cb, c);
-        assert(c->defer_event);
-    }
+        pa_assert_se(c->io_event = c->mainloop->io_new(c->mainloop, c->fd, PA_IO_EVENT_OUTPUT, connect_io_cb, c));
+    } else
+        pa_assert_se(c->defer_event = c->mainloop->defer_new(c->mainloop, connect_fixed_cb, c));
 
     return 0;
 }
 
 pa_socket_client* pa_socket_client_new_ipv4(pa_mainloop_api *m, uint32_t address, uint16_t port) {
     struct sockaddr_in sa;
-    assert(m && port > 0);
-
+    
+    pa_assert(m);
+    pa_assert(port > 0);
+    
     memset(&sa, 0, sizeof(sa));
     sa.sin_family = AF_INET;
     sa.sin_port = htons(port);
     sa.sin_addr.s_addr = htonl(address);
-
+    
     return pa_socket_client_new_sockaddr(m, (struct sockaddr*) &sa, sizeof(sa));
 }
 
@@ -229,7 +246,9 @@
 
 pa_socket_client* pa_socket_client_new_unix(pa_mainloop_api *m, const char *filename) {
     struct sockaddr_un sa;
-    assert(m && filename);
+    
+    pa_assert(m);
+    pa_assert(filename);
 
     memset(&sa, 0, sizeof(sa));
     sa.sun_family = AF_UNIX;
@@ -248,9 +267,9 @@
 #endif /* HAVE_SYS_UN_H */
 
 static int sockaddr_prepare(pa_socket_client *c, const struct sockaddr *sa, size_t salen) {
-    assert(c);
-    assert(sa);
-    assert(salen);
+    pa_assert(c);
+    pa_assert(sa);
+    pa_assert(salen);
 
     switch (sa->sa_family) {
         case AF_UNIX:
@@ -288,9 +307,12 @@
 
 pa_socket_client* pa_socket_client_new_sockaddr(pa_mainloop_api *m, const struct sockaddr *sa, size_t salen) {
     pa_socket_client *c;
-    assert(m && sa);
-    c = pa_socket_client_new(m);
-    assert(c);
+    
+    pa_assert(m);
+    pa_assert(sa);
+    pa_assert(salen > 0);
+    
+    pa_assert_se(c = pa_socket_client_new(m));
 
     if (sockaddr_prepare(c, sa, salen) < 0)
         goto fail;
@@ -300,12 +322,11 @@
 fail:
     pa_socket_client_unref(c);
     return NULL;
-
 }
 
 static void socket_client_free(pa_socket_client *c) {
-    assert(c && c->mainloop);
-
+    pa_assert(c);
+    pa_assert(c->mainloop);
 
     free_events(c);
 
@@ -325,20 +346,25 @@
 }
 
 void pa_socket_client_unref(pa_socket_client *c) {
-    assert(c && c->ref >= 1);
-
-    if (!(--(c->ref)))
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+
+    if (PA_REFCNT_DEC(c) < 0)
         socket_client_free(c);
 }
 
 pa_socket_client* pa_socket_client_ref(pa_socket_client *c) {
-    assert(c && c->ref >= 1);
-    c->ref++;
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+
+    PA_REFCNT_INC(c);
     return c;
 }
 
 void pa_socket_client_set_callback(pa_socket_client *c, void (*on_connection)(pa_socket_client *c, pa_iochannel*io, void *userdata), void *userdata) {
-    assert(c);
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+
     c->callback = on_connection;
     c->userdata = userdata;
 }
@@ -346,6 +372,10 @@
 pa_socket_client* pa_socket_client_new_ipv6(pa_mainloop_api *m, uint8_t address[16], uint16_t port) {
     struct sockaddr_in6 sa;
 
+    pa_assert(m);
+    pa_assert(address);
+    pa_assert(port > 0);
+    
     memset(&sa, 0, sizeof(sa));
     sa.sin6_family = AF_INET6;
     sa.sin6_port = htons(port);
@@ -360,7 +390,12 @@
     pa_socket_client *c = userdata;
     struct addrinfo *res = NULL;
     int ret;
-    assert(m && c && c->asyncns_io_event == e && fd >= 0);
+        
+    pa_assert(m);
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+    pa_assert(c->asyncns_io_event == e);
+    pa_assert(fd >= 0);
 
     if (asyncns_wait(c->asyncns, 0) < 0)
         goto fail;
@@ -397,10 +432,11 @@
 
 static void timeout_cb(pa_mainloop_api *m, pa_time_event *e, const struct timeval *tv, void *userdata) {
     pa_socket_client *c = userdata;
-    assert(m);
-    assert(e);
-    assert(tv);
-    assert(c);
+        
+    pa_assert(m);
+    pa_assert(e);
+    pa_assert(tv);
+    pa_assert(c);
 
     if (c->fd >= 0) {
         pa_close(c->fd);
@@ -413,8 +449,8 @@
 
 static void start_timeout(pa_socket_client *c) {
     struct timeval tv;
-    assert(c);
-    assert(!c->timeout_event);
+    pa_assert(c);
+    pa_assert(!c->timeout_event);
 
     pa_gettimeofday(&tv);
     pa_timeval_add(&tv, CONNECT_TIMEOUT * 1000000);
@@ -424,7 +460,9 @@
 pa_socket_client* pa_socket_client_new_string(pa_mainloop_api *m, const char*name, uint16_t default_port) {
     pa_socket_client *c = NULL;
     pa_parsed_address a;
-    assert(m && name);
+    
+    pa_assert(m);
+    pa_assert(name);
 
     if (pa_parse_address(name, &a) < 0)
         return NULL;
@@ -435,7 +473,7 @@
     switch (a.type) {
         case PA_PARSED_ADDRESS_UNIX:
             if ((c = pa_socket_client_new_unix(m, a.path_or_host)))
-                    start_timeout(c);
+                start_timeout(c);
             break;
 
         case PA_PARSED_ADDRESS_TCP4:  /* Fallthrough */
@@ -462,7 +500,7 @@
                 c->asyncns = asyncns;
                 c->asyncns_io_event = m->io_new(m, asyncns_fd(c->asyncns), PA_IO_EVENT_INPUT, asyncns_cb, c);
                 c->asyncns_query = asyncns_getaddrinfo(c->asyncns, a.path_or_host, port, &hints);
-                assert(c->asyncns_query);
+                pa_assert(c->asyncns_query);
                 start_timeout(c);
             }
 #else /* HAVE_LIBASYNCNS */
@@ -479,7 +517,7 @@
                 if (res->ai_addr) {
                     if ((c = pa_socket_client_new_sockaddr(m, res->ai_addr, res->ai_addrlen)))
                         start_timeout(c);
-                                }
+                }
 
                 freeaddrinfo(res);
 #else /* HAVE_GETADDRINFO */
@@ -507,7 +545,7 @@
                 s.sin_port = htons(a.port);
 
                 if ((c = pa_socket_client_new_sockaddr(m, (struct sockaddr*)&s, sizeof(s))))
-                        start_timeout(c);
+                    start_timeout(c);
 #endif /* HAVE_GETADDRINFO */
             }
 #endif /* HAVE_LIBASYNCNS */
@@ -524,6 +562,8 @@
    local. "local" means UNIX socket or TCP socket on localhost. Other
    local IP addresses are not considered local. */
 int pa_socket_client_is_local(pa_socket_client *c) {
-    assert(c);
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+
     return c->local;
 }

Modified: branches/lennart/src/pulsecore/socket-server.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/socket-server.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/socket-server.c (original)
+++ branches/lennart/src/pulsecore/socket-server.c Tue Sep 11 22:48:33 2007
@@ -27,7 +27,6 @@
 #endif
 
 #include <stdlib.h>
-#include <assert.h>
 #include <errno.h>
 #include <string.h>
 #include <sys/types.h>
@@ -72,12 +71,14 @@
 #include <pulsecore/socket-util.h>
 #include <pulsecore/core-util.h>
 #include <pulsecore/log.h>
+#include <pulsecore/macro.h>
 #include <pulsecore/core-error.h>
+#include <pulsecore/refcnt.h>
 
 #include "socket-server.h"
 
 struct pa_socket_server {
-    int ref;
+    PA_REFCNT_DECLARE;
     int fd;
     char *filename;
     char *tcpwrap_service;
@@ -94,7 +95,14 @@
     pa_socket_server *s = userdata;
     pa_iochannel *io;
     int nfd;
-    assert(s && s->mainloop == mainloop && s->io_event == e && e && fd >= 0 && fd == s->fd);
+    
+    pa_assert(s);
+    pa_assert(PA_REFCNT_VALUE(s) >= 1);
+    pa_assert(s->mainloop == mainloop);
+    pa_assert(s->io_event == e);
+    pa_assert(e);
+    pa_assert(fd >= 0);
+    pa_assert(fd == s->fd);
 
     pa_socket_server_ref(s);
 
@@ -133,8 +141,7 @@
     else
         pa_socket_low_delay(fd);
 
-    io = pa_iochannel_new(s->mainloop, nfd, nfd);
-    assert(io);
+    pa_assert_se(io = pa_iochannel_new(s->mainloop, nfd, nfd));
     s->on_connection(s, io, s->userdata);
 
 finish:
@@ -143,10 +150,12 @@
 
 pa_socket_server* pa_socket_server_new(pa_mainloop_api *m, int fd) {
     pa_socket_server *s;
-    assert(m && fd >= 0);
-
-    s = pa_xmalloc(sizeof(pa_socket_server));
-    s->ref = 1;
+    
+    pa_assert(m);
+    pa_assert(fd >= 0);
+
+    s = pa_xnew(pa_socket_server, 1);
+    PA_REFCNT_INIT(s);
     s->fd = fd;
     s->filename = NULL;
     s->on_connection = NULL;
@@ -154,8 +163,7 @@
     s->tcpwrap_service = NULL;
 
     s->mainloop = m;
-    s->io_event = m->io_new(m, fd, PA_IO_EVENT_INPUT, callback, s);
-    assert(s->io_event);
+    pa_assert_se(s->io_event = m->io_new(m, fd, PA_IO_EVENT_INPUT, callback, s));
 
     s->type = SOCKET_SERVER_GENERIC;
 
@@ -163,8 +171,10 @@
 }
 
 pa_socket_server* pa_socket_server_ref(pa_socket_server *s) {
-    assert(s && s->ref >= 1);
-    s->ref++;
+    pa_assert(s);
+    pa_assert(PA_REFCNT_VALUE(s) >= 1);
+        
+    PA_REFCNT_INC(s);
     return s;
 }
 
@@ -175,7 +185,8 @@
     struct sockaddr_un sa;
     pa_socket_server *s;
 
-    assert(m && filename);
+    pa_assert(m);
+    pa_assert(filename);
 
     if ((fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) {
         pa_log("socket(): %s", pa_cstrerror(errno));
@@ -206,8 +217,7 @@
         goto fail;
     }
 
-    s = pa_socket_server_new(m, fd);
-    assert(s);
+    pa_assert_se(s = pa_socket_server_new(m, fd));
 
     s->filename = pa_xstrdup(filename);
     s->type = SOCKET_SERVER_UNIX;
@@ -235,7 +245,8 @@
     struct sockaddr_in sa;
     int on = 1;
 
-    assert(m && port);
+    pa_assert(m);
+    pa_assert(port);
 
     if ((fd = socket(PF_INET, SOCK_STREAM, 0)) < 0) {
         pa_log("socket(PF_INET): %s", pa_cstrerror(errno));
@@ -286,7 +297,8 @@
     struct sockaddr_in6 sa;
     int on = 1;
 
-    assert(m && port);
+    pa_assert(m);
+    pa_assert(port > 0);
 
     if ((fd = socket(PF_INET6, SOCK_STREAM, 0)) < 0) {
         pa_log("socket(PF_INET6): %s", pa_cstrerror(errno));
@@ -337,29 +349,29 @@
 }
 
 pa_socket_server* pa_socket_server_new_ipv4_loopback(pa_mainloop_api *m, uint16_t port, const char *tcpwrap_service) {
-    assert(m);
-    assert(port > 0);
+    pa_assert(m);
+    pa_assert(port > 0);
 
     return pa_socket_server_new_ipv4(m, INADDR_LOOPBACK, port, tcpwrap_service);
 }
 
 pa_socket_server* pa_socket_server_new_ipv6_loopback(pa_mainloop_api *m, uint16_t port, const char *tcpwrap_service) {
-    assert(m);
-    assert(port > 0);
+    pa_assert(m);
+    pa_assert(port > 0);
 
     return pa_socket_server_new_ipv6(m, in6addr_loopback.s6_addr, port, tcpwrap_service);
 }
 
 pa_socket_server* pa_socket_server_new_ipv4_any(pa_mainloop_api *m, uint16_t port, const char *tcpwrap_service) {
-    assert(m);
-    assert(port > 0);
+    pa_assert(m);
+    pa_assert(port > 0);
 
     return pa_socket_server_new_ipv4(m, INADDR_ANY, port, tcpwrap_service);
 }
 
 pa_socket_server* pa_socket_server_new_ipv6_any(pa_mainloop_api *m, uint16_t port, const char *tcpwrap_service) {
-    assert(m);
-    assert(port > 0);
+    pa_assert(m);
+    pa_assert(port > 0);
 
     return pa_socket_server_new_ipv6(m, in6addr_any.s6_addr, port, tcpwrap_service);
 }
@@ -367,9 +379,9 @@
 pa_socket_server* pa_socket_server_new_ipv4_string(pa_mainloop_api *m, const char *name, uint16_t port, const char *tcpwrap_service) {
     struct in_addr ipv4;
 
-    assert(m);
-    assert(name);
-    assert(port > 0);
+    pa_assert(m);
+    pa_assert(name);
+    pa_assert(port > 0);
 
     if (inet_pton(AF_INET, name, &ipv4) > 0)
         return pa_socket_server_new_ipv4(m, ntohl(ipv4.s_addr), port, tcpwrap_service);
@@ -380,9 +392,9 @@
 pa_socket_server* pa_socket_server_new_ipv6_string(pa_mainloop_api *m, const char *name, uint16_t port, const char *tcpwrap_service) {
     struct in6_addr ipv6;
 
-    assert(m);
-    assert(name);
-    assert(port > 0);
+    pa_assert(m);
+    pa_assert(name);
+    pa_assert(port > 0);
 
     if (inet_pton(AF_INET6, name, &ipv6) > 0)
         return pa_socket_server_new_ipv6(m, ipv6.s6_addr, port, tcpwrap_service);
@@ -391,7 +403,7 @@
 }
 
 static void socket_server_free(pa_socket_server*s) {
-    assert(s);
+    pa_assert(s);
 
     if (s->filename) {
         unlink(s->filename);
@@ -407,21 +419,26 @@
 }
 
 void pa_socket_server_unref(pa_socket_server *s) {
-    assert(s && s->ref >= 1);
-
-    if (!(--(s->ref)))
+    pa_assert(s);
+    pa_assert(PA_REFCNT_VALUE(s) >= 1);
+
+    if (PA_REFCNT_DEC(s))
         socket_server_free(s);
 }
 
 void pa_socket_server_set_callback(pa_socket_server*s, void (*on_connection)(pa_socket_server*s, pa_iochannel *io, void *userdata), void *userdata) {
-    assert(s && s->ref >= 1);
+    pa_assert(s);
+    pa_assert(PA_REFCNT_VALUE(s) >= 1);
 
     s->on_connection = on_connection;
     s->userdata = userdata;
 }
 
 char *pa_socket_server_get_address(pa_socket_server *s, char *c, size_t l) {
-    assert(s && c && l > 0);
+    pa_assert(s);
+    pa_assert(PA_REFCNT_VALUE(s) >= 1);
+    pa_assert(c);
+    pa_assert(l > 0);
 
     switch (s->type) {
         case SOCKET_SERVER_IPV6: {

Modified: branches/lennart/src/pulsecore/socket-util.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/socket-util.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/socket-util.c (original)
+++ branches/lennart/src/pulsecore/socket-util.c Tue Sep 11 22:48:33 2007
@@ -31,7 +31,6 @@
 #include <stdlib.h>
 #include <signal.h>
 #include <errno.h>
-#include <assert.h>
 #include <string.h>
 #include <stdio.h>
 #include <sys/types.h>
@@ -75,19 +74,19 @@
 #include <pulsecore/core-error.h>
 #include <pulsecore/core-util.h>
 #include <pulsecore/log.h>
+#include <pulsecore/macro.h>
 
 #include "socket-util.h"
 
 void pa_socket_peer_to_string(int fd, char *c, size_t l) {
     struct stat st;
 
-    assert(c && l && fd >= 0);
+    pa_assert(fd >= 0);
+    pa_assert(c);
+    pa_assert(l > 0);
 
 #ifndef OS_IS_WIN32
-    if (fstat(fd, &st) < 0) {
-        pa_snprintf(c, l, "Invalid client fd");
-        return;
-    }
+    pa_assert_se(fstat(fd, &st) == 0);
 #endif
 
 #ifndef OS_IS_WIN32
@@ -109,11 +108,11 @@
                 uint32_t ip = ntohl(sa.in.sin_addr.s_addr);
 
                 pa_snprintf(c, l, "TCP/IP client from %i.%i.%i.%i:%u",
-                         ip >> 24,
-                         (ip >> 16) & 0xFF,
-                         (ip >> 8) & 0xFF,
-                         ip & 0xFF,
-                         ntohs(sa.in.sin_port));
+                            ip >> 24,
+                            (ip >> 16) & 0xFF,
+                            (ip >> 8) & 0xFF,
+                            ip & 0xFF,
+                            ntohs(sa.in.sin_port));
                 return;
             } else if (sa.sa.sa_family == AF_INET6) {
                 char buf[INET6_ADDRSTRLEN];
@@ -147,7 +146,7 @@
 int pa_socket_low_delay(int fd) {
 #ifdef SO_PRIORITY
     int priority;
-    assert(fd >= 0);
+    pa_assert(fd >= 0);
 
     priority = 7;
     if (setsockopt(fd, SOL_SOCKET, SO_PRIORITY, (void*)&priority, sizeof(priority)) < 0)
@@ -160,7 +159,7 @@
 int pa_socket_tcp_low_delay(int fd) {
     int ret, tos, on;
 
-    assert(fd >= 0);
+    pa_assert(fd >= 0);
 
     ret = pa_socket_low_delay(fd);
 
@@ -176,8 +175,7 @@
         ret = -1;
 #endif
 
-#if defined(IPTOS_LOWDELAY) && defined(IP_TOS) && (defined(SOL_IP) || \
-        defined(IPPROTO_IP))
+#if defined(IPTOS_LOWDELAY) && defined(IP_TOS) && (defined(SOL_IP) || defined(IPPROTO_IP))
     tos = IPTOS_LOWDELAY;
 #ifdef SOL_IP
     if (setsockopt(fd, SOL_IP, IP_TOS, (void*)&tos, sizeof(tos)) < 0)
@@ -188,27 +186,26 @@
 #endif
 
     return ret;
-
 }
 
 int pa_socket_set_rcvbuf(int fd, size_t l) {
-    assert(fd >= 0);
-
-/*     if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (void*)&l, sizeof(l)) < 0) { */
-/*         pa_log("SO_RCVBUF: %s", strerror(errno)); */
-/*         return -1; */
-/*     } */
+    pa_assert(fd >= 0);
+
+    if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (void*)&l, sizeof(l)) < 0) {
+        pa_log_warn("SO_RCVBUF: %s", pa_cstrerror(errno));
+        return -1;
+    }
 
     return 0;
 }
 
 int pa_socket_set_sndbuf(int fd, size_t l) {
-    assert(fd >= 0);
-
-/*     if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (void*)&l, sizeof(l)) < 0) { */
-/*         pa_log("SO_SNDBUF: %s", strerror(errno)); */
-/*         return -1; */
-/*     } */
+    pa_assert(fd >= 0);
+
+    if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (void*)&l, sizeof(l)) < 0) {
+        pa_log("SO_SNDBUF: %s", pa_cstrerror(errno));
+        return -1;
+    }
 
     return 0;
 }
@@ -218,6 +215,8 @@
 int pa_unix_socket_is_stale(const char *fn) {
     struct sockaddr_un sa;
     int fd = -1, ret = -1;
+
+    pa_assert(fn);
 
     if ((fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) {
         pa_log("socket(): %s", pa_cstrerror(errno));
@@ -244,6 +243,8 @@
 int pa_unix_socket_remove_stale(const char *fn) {
     int r;
 
+    pa_assert(fn);
+
     if ((r = pa_unix_socket_is_stale(fn)) < 0)
         return errno != ENOENT ? -1 : 0;
 

Modified: branches/lennart/src/pulsecore/source.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/source.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/source.c (original)
+++ branches/lennart/src/pulsecore/source.c Tue Sep 11 22:48:33 2007
@@ -27,7 +27,6 @@
 #endif
 
 #include <stdio.h>
-#include <assert.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -56,12 +55,11 @@
 
     pa_source *s;
     char st[256];
-    int r;
     pa_channel_map tmap;
 
-    assert(core);
-    assert(name);
-    assert(spec);
+    pa_assert(core);
+    pa_assert(name);
+    pa_assert(spec);
 
     pa_return_null_if_fail(pa_sample_spec_valid(spec));
 
@@ -112,8 +110,7 @@
     s->asyncmsgq = NULL;
     s->rtpoll = NULL;
 
-    r = pa_idxset_put(core->sources, s, &s->index);
-    assert(s->index != PA_IDXSET_INVALID && r >= 0);
+    pa_assert_se(pa_idxset_put(core->sources, s, &s->index) >= 0);
 
     pa_sample_spec_snprint(st, sizeof(st), spec);
     pa_log_info("Created source %u \"%s\" with sample spec \"%s\"", s->index, s->name, st);

Modified: branches/lennart/src/pulsecore/strbuf.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/strbuf.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/strbuf.c (original)
+++ branches/lennart/src/pulsecore/strbuf.c Tue Sep 11 22:48:33 2007
@@ -82,7 +82,7 @@
     e = t = pa_xnew(char, sb->length+1);
 
     for (c = sb->head; c; c = c->next) {
-        assert((size_t) (e-t) <= sb->length);
+        pa_assert((size_t) (e-t) <= sb->length);
         memcpy(e, CHUNK_TO_TEXT(c), c->length);
         e += c->length;
     }
@@ -90,7 +90,7 @@
     /* Trailing NUL */
     *e = 0;
 
-    assert(e == t+sb->length);
+    pa_assert(e == t+sb->length);
 
     return t;
 }

Modified: branches/lennart/src/pulsecore/tagstruct.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/tagstruct.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/tagstruct.c (original)
+++ branches/lennart/src/pulsecore/tagstruct.c Tue Sep 11 22:48:33 2007
@@ -29,19 +29,18 @@
 #include <string.h>
 #include <unistd.h>
 #include <sys/time.h>
-#include <assert.h>
 #include <stdarg.h>
 
 #ifdef HAVE_NETINET_IN_H
 #include <netinet/in.h>
 #endif
 
-#include "winsock.h"
-
 #include <pulse/xmalloc.h>
 
+#include <pulsecore/winsock.h>
+#include <pulsecore/macro.h>
+
 #include "tagstruct.h"
-
 
 struct pa_tagstruct {
     uint8_t *data;
@@ -54,18 +53,20 @@
 pa_tagstruct *pa_tagstruct_new(const uint8_t* data, size_t length) {
     pa_tagstruct*t;
 
-    assert(!data || (data && length));
-
-    t = pa_xmalloc(sizeof(pa_tagstruct));
+    pa_assert(!data || (data && length));
+
+    t = pa_xnew(pa_tagstruct, 1);
     t->data = (uint8_t*) data;
     t->allocated = t->length = data ? length : 0;
     t->rindex = 0;
     t->dynamic = !data;
+    
     return t;
 }
 
 void pa_tagstruct_free(pa_tagstruct*t) {
-    assert(t);
+    pa_assert(t);
+
     if (t->dynamic)
         pa_xfree(t->data);
     pa_xfree(t);
@@ -73,7 +74,11 @@
 
 uint8_t* pa_tagstruct_free_data(pa_tagstruct*t, size_t *l) {
     uint8_t *p;
-    assert(t && t->dynamic && l);
+    
+    pa_assert(t);
+    pa_assert(t->dynamic);
+    pa_assert(l);
+    
     p = t->data;
     *l = t->length;
     pa_xfree(t);
@@ -81,8 +86,8 @@
 }
 
 static void extend(pa_tagstruct*t, size_t l) {
-    assert(t);
-    assert(t->dynamic);
+    pa_assert(t);
+    pa_assert(t->dynamic);
 
     if (t->length+l <= t->allocated)
         return;
@@ -92,7 +97,8 @@
 
 void pa_tagstruct_puts(pa_tagstruct*t, const char *s) {
     size_t l;
-    assert(t);
+    pa_assert(t);
+    
     if (s) {
         l = strlen(s)+2;
         extend(t, l);
@@ -107,7 +113,8 @@
 }
 
 void pa_tagstruct_putu32(pa_tagstruct*t, uint32_t i) {
-    assert(t);
+    pa_assert(t);
+    
     extend(t, 5);
     t->data[t->length] = PA_TAG_U32;
     i = htonl(i);
@@ -116,7 +123,8 @@
 }
 
 void pa_tagstruct_putu8(pa_tagstruct*t, uint8_t c) {
-    assert(t);
+    pa_assert(t);
+    
     extend(t, 2);
     t->data[t->length] = PA_TAG_U8;
     *(t->data+t->length+1) = c;
@@ -125,7 +133,10 @@
 
 void pa_tagstruct_put_sample_spec(pa_tagstruct *t, const pa_sample_spec *ss) {
     uint32_t rate;
-    assert(t && ss);
+    
+    pa_assert(t);
+    pa_assert(ss);
+    
     extend(t, 7);
     t->data[t->length] = PA_TAG_SAMPLE_SPEC;
     t->data[t->length+1] = (uint8_t) ss->format;
@@ -137,7 +148,9 @@
 
 void pa_tagstruct_put_arbitrary(pa_tagstruct *t, const void *p, size_t length) {
     uint32_t tmp;
-    assert(t && p);
+    
+    pa_assert(t);
+    pa_assert(p);
 
     extend(t, 5+length);
     t->data[t->length] = PA_TAG_ARBITRARY;
@@ -149,7 +162,8 @@
 }
 
 void pa_tagstruct_put_boolean(pa_tagstruct*t, int b) {
-    assert(t);
+    pa_assert(t);
+
     extend(t, 1);
     t->data[t->length] = b ? PA_TAG_BOOLEAN_TRUE : PA_TAG_BOOLEAN_FALSE;
     t->length += 1;
@@ -157,7 +171,8 @@
 
 void pa_tagstruct_put_timeval(pa_tagstruct*t, const struct timeval *tv) {
     uint32_t tmp;
-    assert(t);
+    pa_assert(t);
+
     extend(t, 9);
     t->data[t->length] = PA_TAG_TIMEVAL;
     tmp = htonl(tv->tv_sec);
@@ -169,7 +184,9 @@
 
 void pa_tagstruct_put_usec(pa_tagstruct*t, pa_usec_t u) {
     uint32_t tmp;
-    assert(t);
+    
+    pa_assert(t);
+
     extend(t, 9);
     t->data[t->length] = PA_TAG_USEC;
     tmp = htonl((uint32_t) (u >> 32));
@@ -181,7 +198,9 @@
 
 void pa_tagstruct_putu64(pa_tagstruct*t, uint64_t u) {
     uint32_t tmp;
-    assert(t);
+    
+    pa_assert(t);
+
     extend(t, 9);
     t->data[t->length] = PA_TAG_U64;
     tmp = htonl((uint32_t) (u >> 32));
@@ -193,7 +212,9 @@
 
 void pa_tagstruct_puts64(pa_tagstruct*t, int64_t u) {
     uint32_t tmp;
-    assert(t);
+    
+    pa_assert(t);
+
     extend(t, 9);
     t->data[t->length] = PA_TAG_S64;
     tmp = htonl((uint32_t) ((uint64_t) u >> 32));
@@ -206,7 +227,7 @@
 void pa_tagstruct_put_channel_map(pa_tagstruct *t, const pa_channel_map *map) {
     unsigned i;
 
-    assert(t);
+    pa_assert(t);
     extend(t, 2 + map->channels);
 
     t->data[t->length++] = PA_TAG_CHANNEL_MAP;
@@ -220,7 +241,7 @@
     unsigned i;
     pa_volume_t vol;
 
-    assert(t);
+    pa_assert(t);
     extend(t, 2 + cvolume->channels * sizeof(pa_volume_t));
 
     t->data[t->length++] = PA_TAG_CVOLUME;
@@ -237,7 +258,9 @@
     int error = 0;
     size_t n;
     char *c;
-    assert(t && s);
+    
+    pa_assert(t);
+    pa_assert(s);
 
     if (t->rindex+1 > t->length)
         return -1;
@@ -271,7 +294,8 @@
 }
 
 int pa_tagstruct_getu32(pa_tagstruct*t, uint32_t *i) {
-    assert(t && i);
+    pa_assert(t);
+    pa_assert(i);
 
     if (t->rindex+5 > t->length)
         return -1;
@@ -286,7 +310,8 @@
 }
 
 int pa_tagstruct_getu8(pa_tagstruct*t, uint8_t *c) {
-    assert(t && c);
+    pa_assert(t);
+    pa_assert(c);
 
     if (t->rindex+2 > t->length)
         return -1;
@@ -300,7 +325,8 @@
 }
 
 int pa_tagstruct_get_sample_spec(pa_tagstruct *t, pa_sample_spec *ss) {
-    assert(t && ss);
+    pa_assert(t);
+    pa_assert(ss);
 
     if (t->rindex+7 > t->length)
         return -1;
@@ -319,7 +345,9 @@
 
 int pa_tagstruct_get_arbitrary(pa_tagstruct *t, const void **p, size_t length) {
     uint32_t len;
-    assert(t && p);
+    
+    pa_assert(t);
+    pa_assert(p);
 
     if (t->rindex+5+length > t->length)
         return -1;
@@ -337,19 +365,24 @@
 }
 
 int pa_tagstruct_eof(pa_tagstruct*t) {
-    assert(t);
+    pa_assert(t);
+    
     return t->rindex >= t->length;
 }
 
 const uint8_t* pa_tagstruct_data(pa_tagstruct*t, size_t *l) {
-    assert(t && t->dynamic && l);
+    pa_assert(t);
+    pa_assert(t->dynamic);
+    pa_assert(l);
+    
     *l = t->length;
     return t->data;
 }
 
 int pa_tagstruct_get_boolean(pa_tagstruct*t, int *b) {
-    assert(t && b);
-
+    pa_assert(t);
+    pa_assert(b);
+    
     if (t->rindex+1 > t->length)
         return -1;
 
@@ -366,6 +399,9 @@
 
 int pa_tagstruct_get_timeval(pa_tagstruct*t, struct timeval *tv) {
 
+    pa_assert(t);
+    pa_assert(tv);
+    
     if (t->rindex+9 > t->length)
         return -1;
 
@@ -382,7 +418,9 @@
 
 int pa_tagstruct_get_usec(pa_tagstruct*t, pa_usec_t *u) {
     uint32_t tmp;
-    assert(t && u);
+
+    pa_assert(t);
+    pa_assert(u);
 
     if (t->rindex+9 > t->length)
         return -1;
@@ -400,7 +438,9 @@
 
 int pa_tagstruct_getu64(pa_tagstruct*t, uint64_t *u) {
     uint32_t tmp;
-    assert(t && u);
+
+    pa_assert(t);
+    pa_assert(u);
 
     if (t->rindex+9 > t->length)
         return -1;
@@ -418,7 +458,9 @@
 
 int pa_tagstruct_gets64(pa_tagstruct*t, int64_t *u) {
     uint32_t tmp;
-    assert(t && u);
+    
+    pa_assert(t);
+    pa_assert(u);
 
     if (t->rindex+9 > t->length)
         return -1;
@@ -437,8 +479,8 @@
 int pa_tagstruct_get_channel_map(pa_tagstruct *t, pa_channel_map *map) {
     unsigned i;
 
-    assert(t);
-    assert(map);
+    pa_assert(t);
+    pa_assert(map);
 
     if (t->rindex+2 > t->length)
         return -1;
@@ -463,8 +505,8 @@
     unsigned i;
     pa_volume_t vol;
 
-    assert(t);
-    assert(cvolume);
+    pa_assert(t);
+    pa_assert(cvolume);
 
     if (t->rindex+2 > t->length)
         return -1;
@@ -489,7 +531,7 @@
 
 void pa_tagstruct_put(pa_tagstruct *t, ...) {
     va_list va;
-    assert(t);
+    pa_assert(t);
 
     va_start(va, t);
 
@@ -550,7 +592,7 @@
                 break;
 
             default:
-                abort();
+                pa_assert_not_reached();
         }
     }
 
@@ -561,7 +603,7 @@
     va_list va;
     int ret = 0;
 
-    assert(t);
+    pa_assert(t);
 
     va_start(va, t);
     while (ret == 0) {
@@ -620,9 +662,8 @@
                 ret = pa_tagstruct_get_cvolume(t, va_arg(va, pa_cvolume *));
                 break;
 
-
             default:
-                abort();
+                pa_assert_not_reached();
         }
 
     }

Modified: branches/lennart/src/pulsecore/tokenizer.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/tokenizer.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/tokenizer.c (original)
+++ branches/lennart/src/pulsecore/tokenizer.c Tue Sep 11 22:48:33 2007
@@ -26,19 +26,15 @@
 #endif
 
 #include <string.h>
-#include <assert.h>
 #include <stdlib.h>
 
 #include <pulse/xmalloc.h>
 
 #include <pulsecore/dynarray.h>
 #include <pulsecore/gccmacro.h>
+#include <pulsecore/macro.h>
 
 #include "tokenizer.h"
-
-struct pa_tokenizer {
-    pa_dynarray *dynarray;
-};
 
 static void token_free(void *p, PA_GCC_UNUSED void *userdata) {
     pa_xfree(p);
@@ -48,7 +44,9 @@
     int infty = 0;
     const char delimiter[] = " \t\n\r";
     const char *p;
-    assert(a && s);
+    
+    pa_assert(a);
+    pa_assert(s);
 
     if (args == 0)
         infty = 1;
@@ -70,23 +68,23 @@
 }
 
 pa_tokenizer* pa_tokenizer_new(const char *s, unsigned args) {
-    pa_tokenizer *t;
+    pa_dynarray *a;
 
-    t = pa_xmalloc(sizeof(pa_tokenizer));
-    t->dynarray = pa_dynarray_new();
-    assert(t->dynarray);
-
-    parse(t->dynarray, s, args);
-    return t;
+    a = pa_dynarray_new();
+    parse(a, s, args);
+    return (pa_tokenizer*) a;
 }
 
 void pa_tokenizer_free(pa_tokenizer *t) {
-    assert(t);
-    pa_dynarray_free(t->dynarray, token_free, NULL);
-    pa_xfree(t);
+    pa_dynarray *a = (pa_dynarray*) t;
+    
+    pa_assert(a);
+    pa_dynarray_free(a, token_free, NULL);
 }
 
 const char *pa_tokenizer_get(pa_tokenizer *t, unsigned i) {
-    assert(t);
-    return pa_dynarray_get(t->dynarray, i);
+    pa_dynarray *a = (pa_dynarray*) t;
+
+    pa_assert(a);
+    return pa_dynarray_get(a, i);
 }

Modified: branches/lennart/src/pulsecore/x11prop.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/x11prop.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/x11prop.c (original)
+++ branches/lennart/src/pulsecore/x11prop.c Tue Sep 11 22:48:33 2007
@@ -31,7 +31,6 @@
 #include <X11/Xatom.h>
 
 #include "x11prop.h"
-
 
 void pa_x11_set_prop(Display *d, const char *name, const char *data) {
     Atom a = XInternAtom(d, name, False);

Modified: branches/lennart/src/pulsecore/x11wrap.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/x11wrap.c?rev=1809&root=pulseaudio&r1=1808&r2=1809&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/x11wrap.c (original)
+++ branches/lennart/src/pulsecore/x11wrap.c Tue Sep 11 22:48:33 2007
@@ -25,7 +25,6 @@
 #include <config.h>
 #endif
 
-#include <assert.h>
 #include <stdio.h>
 
 #include <pulse/xmalloc.h>
@@ -34,6 +33,7 @@
 #include <pulsecore/log.h>
 #include <pulsecore/props.h>
 #include <pulsecore/core-util.h>
+#include <pulsecore/macro.h>
 
 #include "x11wrap.h"
 
@@ -47,8 +47,8 @@
 };
 
 struct pa_x11_wrapper {
+    PA_REFCNT_DECLARE;
     pa_core *core;
-    int ref;
 
     char *property_name;
     Display *display;
@@ -69,7 +69,8 @@
 
 /* Dispatch all pending X11 events */
 static void work(pa_x11_wrapper *w) {
-    assert(w && w->ref >= 1);
+    pa_assert(w);
+    pa_assert(PA_REFCNT_VALUE(w) >= 1);
 
     while (XPending(w->display)) {
         pa_x11_client *c;
@@ -77,7 +78,7 @@
         XNextEvent(w->display, &e);
 
         for (c = w->clients; c; c = c->next) {
-            assert(c->callback);
+            pa_assert(c->callback);
             if (c->callback(w, &e, c->userdata) != 0)
                 break;
         }
@@ -87,14 +88,24 @@
 /* IO notification event for the X11 display connection */
 static void display_io_event(pa_mainloop_api *m, pa_io_event *e, int fd, PA_GCC_UNUSED pa_io_event_flags_t f, void *userdata) {
     pa_x11_wrapper *w = userdata;
-    assert(m && e && fd >= 0 && w && w->ref >= 1);
+
+    pa_assert(m);
+    pa_assert(e);
+    pa_assert(fd >= 0);
+    pa_assert(w);
+    pa_assert(PA_REFCNT_VALUE(w) >= 1);
+
     work(w);
 }
 
 /* Deferred notification event. Called once each main loop iteration */
 static void defer_event(pa_mainloop_api *m, pa_defer_event *e, void *userdata) {
     pa_x11_wrapper *w = userdata;
-    assert(m && e && w && w->ref >= 1);
+
+    pa_assert(m);
+    pa_assert(e);
+    pa_assert(w);
+    pa_assert(PA_REFCNT_VALUE(w) >= 1);
 
     m->defer_enable(e, 0);
 
@@ -104,7 +115,12 @@
 /* IO notification event for X11 internal connections */
 static void internal_io_event(pa_mainloop_api *m, pa_io_event *e, int fd, PA_GCC_UNUSED pa_io_event_flags_t f, void *userdata) {
     pa_x11_wrapper *w = userdata;
-    assert(m && e && fd >= 0 && w && w->ref >= 1);
+    
+    pa_assert(m);
+    pa_assert(e);
+    pa_assert(fd >= 0);
+    pa_assert(w);
+    pa_assert(PA_REFCNT_VALUE(w) >= 1);
 
     XProcessInternalConnection(w->display, fd);
 
@@ -114,10 +130,9 @@
 /* Add a new IO source for the specified X11 internal connection */
 static pa_x11_internal* x11_internal_add(pa_x11_wrapper *w, int fd) {
     pa_x11_internal *i;
-    assert(fd >= 0);
-
-    i = pa_xmalloc(sizeof(pa_x11_internal));
-    assert(i);
+    pa_assert(fd >= 0);
+
+    i = pa_xnew(pa_x11_internal, 1);
     i->wrapper = w;
     i->io_event = w->core->mainloop->io_new(w->core->mainloop, fd, PA_IO_EVENT_INPUT, internal_io_event, w);
     i->fd = fd;
@@ -128,7 +143,7 @@
 
 /* Remove an IO source for an X11 internal connection */
 static void x11_internal_remove(pa_x11_wrapper *w, pa_x11_internal *i) {
-    assert(i);
+    pa_assert(i);
 
     PA_LLIST_REMOVE(pa_x11_internal, w->internals, i);
     w->core->mainloop->io_free(i->io_event);
@@ -138,7 +153,10 @@
 /* Implementation of XConnectionWatchProc */
 static void x11_watch(Display *display, XPointer userdata, int fd, Bool opening, XPointer *watch_data) {
     pa_x11_wrapper *w = (pa_x11_wrapper*) userdata;
-    assert(display && w && fd >= 0);
+    
+    pa_assert(display);
+    pa_assert(w);
+    pa_assert(fd >= 0);
 
     if (opening)
         *watch_data = (XPointer) x11_internal_add(w, fd);
@@ -149,16 +167,15 @@
 static pa_x11_wrapper* x11_wrapper_new(pa_core *c, const char *name, const char *t) {
     pa_x11_wrapper*w;
     Display *d;
-    int r;
 
     if (!(d = XOpenDisplay(name))) {
         pa_log("XOpenDisplay() failed");
         return NULL;
     }
 
-    w = pa_xmalloc(sizeof(pa_x11_wrapper));
+    w = pa_xnew(pa_x11_wrapper, 1);
+    PA_REFCNT_INIT(w);
     w->core = c;
-    w->ref = 1;
     w->property_name = pa_xstrdup(t);
     w->display = d;
 
@@ -170,20 +187,17 @@
 
     XAddConnectionWatch(d, x11_watch, (XPointer) w);
 
-    r = pa_property_set(c, w->property_name, w);
-    assert(r >= 0);
+    pa_assert_se(pa_property_set(c, w->property_name, w) >= 0);
 
     return w;
 }
 
 static void x11_wrapper_free(pa_x11_wrapper*w) {
-    int r;
-    assert(w);
-
-    r = pa_property_remove(w->core, w->property_name);
-    assert(r >= 0);
-
-    assert(!w->clients);
+    pa_assert(w);
+
+    pa_assert_se(pa_property_remove(w->core, w->property_name) >= 0);
+
+    pa_assert(!w->clients);
 
     XRemoveConnectionWatch(w->display, x11_watch, (XPointer) w);
     XCloseDisplay(w->display);
@@ -201,7 +215,8 @@
 pa_x11_wrapper* pa_x11_wrapper_get(pa_core *c, const char *name) {
     char t[256];
     pa_x11_wrapper *w;
-    assert(c);
+    
+    pa_core_assert_ref(c);
 
     pa_snprintf(t, sizeof(t), "x11-wrapper%s%s", name ? "-" : "", name ? name : "");
     if ((w = pa_property_get(c, t)))
@@ -211,20 +226,24 @@
 }
 
 pa_x11_wrapper* pa_x11_wrapper_ref(pa_x11_wrapper *w) {
-    assert(w && w->ref >= 1);
-    w->ref++;
+    pa_assert(w);
+    pa_assert(PA_REFCNT_VALUE(w) >= 1);
+
+    PA_REFCNT_INC(w);
     return w;
 }
 
 void pa_x11_wrapper_unref(pa_x11_wrapper* w) {
-    assert(w && w->ref >= 1);
-
-    if (!(--w->ref))
+    pa_assert(w);
+    pa_assert(PA_REFCNT_VALUE(w) >= 1);
+
+    if (PA_REFCNT_DEC(w) <= 0)
         x11_wrapper_free(w);
 }
 
 Display *pa_x11_wrapper_get_display(pa_x11_wrapper *w) {
-    assert(w && w->ref >= 1);
+    pa_assert(w);
+    pa_assert(PA_REFCNT_VALUE(w) >= 1);
 
     /* Somebody is using us, schedule a output buffer flush */
     w->core->mainloop->defer_enable(w->defer_event, 1);
@@ -234,9 +253,11 @@
 
 pa_x11_client* pa_x11_client_new(pa_x11_wrapper *w, int (*cb)(pa_x11_wrapper *w, XEvent *e, void *userdata), void *userdata) {
     pa_x11_client *c;
-    assert(w && w->ref >= 1);
-
-    c = pa_xmalloc(sizeof(pa_x11_client));
+    
+    pa_assert(w);
+    pa_assert(PA_REFCNT_VALUE(w) >= 1);
+
+    c = pa_xnew(pa_x11_client, 1);
     c->wrapper = w;
     c->callback = cb;
     c->userdata = userdata;
@@ -247,8 +268,10 @@
 }
 
 void pa_x11_client_free(pa_x11_client *c) {
-    assert(c && c->wrapper && c->wrapper->ref >= 1);
-
+    pa_assert(c);
+    pa_assert(c->wrapper);
+    pa_assert(PA_REFCNT_VALUE(c->wrapper) >= 1);
+    
     PA_LLIST_REMOVE(pa_x11_client, c->wrapper->clients, c);
     pa_xfree(c);
 }




More information about the pulseaudio-commits mailing list