Reputation: 1032
I've been trying to iterate through a directory using this sample which I found with a quick google search:
namespace bf = boost::filesystem;
bf::path p("somedir");
bf::directory_iterator end_iter;
for (bf::directory_iterator iter(p); iter != end_iter; ++iter) {
}
However, when running this through Terminal, the default constructor causes this:
testapp(6538) malloc: *** error for object 0x10fee9820: pointer being freed was not allocated
. Further debugging showed that this occurs in the constructor of the directory_iterator. Has this happened to anyone else?
If I run this through NetBeans everything runs fine.
I use OSX 10.8.3 and GCC 4.8
Upvotes: 4
Views: 1672
Reputation: 111
I ran into this exact issue. For me, the problem ended up being that the Boost libraries were compiled with a different C++ compiler than I was using on my project (clang for Boost and gcc for my stuff). I recompiled Boost with GCC and success.
Upvotes: 1