[vlc-commits] commit: Revert "skins: use readdir_r() instead of readdir()" ( Rémi Denis-Courmont )

git at videolan.org git at videolan.org
Fri Sep 10 03:45:31 CEST 2010


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri Sep 10 04:43:44 2010 +0300| [11d4295550ce6496001c34d90e8ad9c9fbeaadf4] | committer: Rémi Denis-Courmont 

Revert "skins: use readdir_r() instead of readdir()"

This reverts commit 4bf419574b51ced5dea893f9e247fe38a2a0d163.

This is not needed. readdir() uses one dirent buffer per DIR pointer,
not per process. In other words, as long as a given DIR pointer is used
in a single thread, readdir() is thread-safe.

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

 modules/gui/skins2/x11/x11_factory.cpp |    9 ++-------
 1 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/modules/gui/skins2/x11/x11_factory.cpp b/modules/gui/skins2/x11/x11_factory.cpp
index a916cfa..0a07681 100644
--- a/modules/gui/skins2/x11/x11_factory.cpp
+++ b/modules/gui/skins2/x11/x11_factory.cpp
@@ -208,11 +208,6 @@ void X11Factory::getMousePos( int &rXPos, int &rYPos ) const
 
 void X11Factory::rmDir( const string &rPath )
 {
-    struct
-    {
-        struct dirent ent;
-        char buf[NAME_MAX + 1];
-    } buf;
     struct dirent *file;
     DIR *dir;
 
@@ -220,7 +215,7 @@ void X11Factory::rmDir( const string &rPath )
     if( !dir ) return;
 
     // Parse the directory and remove everything it contains
-    while( readdir_r( dir, &buf.ent, &file ) == 0 && file != NULL )
+    while( (file = readdir( dir )) )
     {
         struct stat statbuf;
         string filename = file->d_name;
@@ -233,7 +228,7 @@ void X11Factory::rmDir( const string &rPath )
 
         filename = rPath + "/" + filename;
 
-        if( !stat( filename.c_str(), &statbuf ) && S_ISDIR(statbuf.st_mode) )
+        if( !stat( filename.c_str(), &statbuf ) && statbuf.st_mode & S_IFDIR )
         {
             rmDir( filename );
         }



More information about the vlc-commits mailing list