From 854ec81bfcffd6f0e5939789b0ffbc410f7910b7 Mon Sep 17 00:00:00 2001 From: malaterre Date: Mon, 7 Jun 2004 20:16:29 +0000 Subject: [PATCH] ENH: scandir was leaking like crazy, we shouldnt be using this function anyway --- src/gdcmDirList.cxx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gdcmDirList.cxx b/src/gdcmDirList.cxx index 5f8f3ccc..e3a00ccc 100644 --- a/src/gdcmDirList.cxx +++ b/src/gdcmDirList.cxx @@ -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 } -- 2.48.1