[Lldb-commits] [lldb] r124648 - /lldb/trunk/source/Host/macosx/Symbols.cpp

Greg Clayton gclayton at apple.com
Mon Jan 31 21:15:02 PST 2011


Author: gclayton
Date: Mon Jan 31 23:15:02 2011
New Revision: 124648

URL: http://llvm.org/viewvc/llvm-project?rev=124648&view=rev
Log:
Added a cleanup helper object to make sure the directory that was opened with "DIR *opendir(const char *)" is closed if it is valid with a call to "int closedir (DIR *)".

Modified:
    lldb/trunk/source/Host/macosx/Symbols.cpp

Modified: lldb/trunk/source/Host/macosx/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Symbols.cpp?rev=124648&r1=124647&r2=124648&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/Symbols.cpp (original)
+++ lldb/trunk/source/Host/macosx/Symbols.cpp Mon Jan 31 23:15:02 2011
@@ -25,6 +25,7 @@
 #include "lldb/Core/Timer.h"
 #include "lldb/Core/UUID.h"
 #include "lldb/Host/Endian.h"
+#include "lldb/Utility/CleanUp.h"
 
 #include "Host/macosx/cfcpp/CFCReleaser.h"
 #include "mach/machine.h"
@@ -237,12 +238,12 @@
     {
         ::strncat (path, "/Contents/Resources/DWARF", sizeof(path) - strlen(path) - 1);
 
-        DIR* dirp = ::opendir(path);
-        if (dirp != NULL)
+        lldb_utility::CleanUp <DIR *, int> dirp (opendir("containing_part"), NULL, closedir);
+        if (dirp.is_valid())
         {
             dsym_fspec.GetDirectory().SetCString(path);
             struct dirent* dp;
-            while ((dp = readdir(dirp)) != NULL)
+            while ((dp = readdir(dirp.get())) != NULL)
             {
                 // Only search directories
                 if (dp->d_type == DT_DIR || dp->d_type == DT_UNKNOWN)





More information about the lldb-commits mailing list