]> Creatis software - gdcm.git/commitdiff
ENH: scandir was leaking like crazy, we shouldnt be using this function anyway
authormalaterre <malaterre>
Mon, 7 Jun 2004 20:16:29 +0000 (20:16 +0000)
committermalaterre <malaterre>
Mon, 7 Jun 2004 20:16:29 +0000 (20:16 +0000)
src/gdcmDirList.cxx

index 5f8f3ccc2536bb4eb548efe2ed4dced09dec67a3..e3a00ccce225bb5f5370a537021fed66ee66f0de 100644 (file)
@@ -92,9 +92,15 @@ void gdcmDirList::Explore(std::string dirName,bool recursive)
    }
 
 #else
+   // None  of  these  functions  is  in  POSIX.  The functions scandir() and
+   // alphasort() are from BSD 4.3, and have been available under Linux since
+   // libc4.  Libc4 and libc5 use the more precise prototype
+
    struct dirent **namelist;
    int n=scandir(dirName.c_str(), &namelist, 0, alphasort);
 
+   //if n < 0 should raise error
+
    for (int i= 0;i < n; i++) 
    {
       fileName=namelist[i]->d_name;     
@@ -107,7 +113,9 @@ void gdcmDirList::Explore(std::string dirName,bool recursive)
       {
          this->push_back(dirName+fileName);
       }
+      free(namelist[i]);
    }
+   free(namelist);
 #endif
 }