[vlc-commits] commit: config_PutPsz: reduce lock contention scope ( Rémi Denis-Courmont )

git at videolan.org git at videolan.org
Sat May 29 17:29:22 CEST 2010


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat May 29 18:25:07 2010 +0300| [2f5357149a3c7597de173884f85a87fefe24064e] | committer: Rémi Denis-Courmont 

config_PutPsz: reduce lock contention scope

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2f5357149a3c7597de173884f85a87fefe24064e
---

 src/config/core.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/config/core.c b/src/config/core.c
index 8f4cdc7..24925ef 100644
--- a/src/config/core.c
+++ b/src/config/core.c
@@ -271,16 +271,17 @@ void config_PutPsz( vlc_object_t *p_this,
         return;
     }
 
-    vlc_rwlock_wrlock (&config_lock);
+    char *str;
+    if ((psz_value != NULL) && *psz_value)
+        str = strdup (psz_value);
+    else
+        str = NULL;
 
+    vlc_rwlock_wrlock (&config_lock);
     /* backup old value */
     oldval.psz_string = (char *)p_config->value.psz;
 
-    if ((psz_value != NULL) && *psz_value)
-        p_config->value.psz = strdup (psz_value);
-    else
-        p_config->value.psz = NULL;
-
+    p_config->value.psz = str;
     p_config->b_dirty = true;
 
     val.psz_string = (char *)p_config->value.psz;



More information about the vlc-commits mailing list