]> code.delx.au - pulseaudio/commitdiff
pulsecore: Make run-from-build not readlink() on every call
authorArun Raghavan <arun.raghavan@collabora.co.uk>
Sat, 20 Apr 2013 04:42:34 +0000 (10:12 +0530)
committerArun Raghavan <arun.raghavan@collabora.co.uk>
Sat, 20 Apr 2013 04:42:34 +0000 (10:12 +0530)
Since this is no longer only defined in debug builds, let's make sure
that there is no impact if this is indavertently called repeatedly at
startup.

src/pulsecore/core-util.c

index 657e50085c783556b26c08f4ead8c3523f438c9b..96cf4e837bee9725b0f3f15017ac420ce1f62887 100644 (file)
@@ -3209,12 +3209,14 @@ void pa_reset_personality(void) {
 
 pa_bool_t pa_run_from_build_tree(void) {
     char *rp;
-    pa_bool_t b = FALSE;
+    static pa_bool_t b = FALSE;
 
-    if ((rp = pa_readlink("/proc/self/exe"))) {
-        b = pa_startswith(rp, PA_BUILDDIR);
-        pa_xfree(rp);
-    }
+    PA_ONCE_BEGIN {
+        if ((rp = pa_readlink("/proc/self/exe"))) {
+            b = pa_startswith(rp, PA_BUILDDIR);
+            pa_xfree(rp);
+        }
+    } PA_ONCE_END;
 
     return b;
 }