Heap vs. Stack allocation of filtering_streambuf??

Hi Folks - I'm working on a mod to an existing program to write compressed
output files. The following code works fine, but if I put the indicated
code in a function, it drops core when I attempt to write to the ofile
ostream - presumably because the filtering_streambuf<output> out was
allocated on the stack and no longer exists after the function exits.
#include <fstream>
#include <iostream>
#include <string>
#include

On Thu, Nov 19, 2009 at 10:44:52AM -0700, Eric R George
This code compiles and runs fine, but the compressed output file, 00011.eph.org.bz2, ends up empty. Moving the indicated code to a function again works fine - but again, no output??
I'm not an iostreams expert, but I bet you need to flush and/or close your stream. If you were deleting it (something you also want to do) that would probably do it for you. Daniel

Yea, turned out to be something like that. I had tried flushing the
ostream (ofile) and the fstream (file2),and had tried deleting them also.
But I needed to also flush the filtering_streambuf (out),
Thanks for the help,
Eric
Daniel Burrows
This code compiles and runs fine, but the compressed output file, 00011.eph.org.bz2, ends up empty. Moving the indicated code to a function again works fine - but again, no output??
I'm not an iostreams expert, but I bet you need to flush and/or close your stream. If you were deleting it (something you also want to do) that would probably do it for you. Daniel _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Daniel Burrows
-
Eric R George