backported 2008-05-12T23:34:38Z!paniemin@cc.hut.fi to stable (memory leaks fixes)

This commit is contained in:
Pauli Nieminen 2008-05-13 11:11:38 +00:00
parent c246da918d
commit ad4ecd8493
3 changed files with 20 additions and 4 deletions

View file

@ -916,13 +916,16 @@ struct preprocessor_deleter: std::basic_istream<char>
{
preprocessor_streambuf *buf_;
preproc_map *defines_;
std::vector<std::string> *callstack_;
std::string *error_log;
preprocessor_deleter(preprocessor_streambuf *buf, preproc_map *defines);
preprocessor_deleter(preprocessor_streambuf *buf, preproc_map *defines, std::vector<std::string>*);
~preprocessor_deleter();
};
preprocessor_deleter::preprocessor_deleter(preprocessor_streambuf *buf, preproc_map *defines)
: std::basic_istream<char>(buf), buf_(buf), defines_(defines), error_log(buf->error_log)
preprocessor_deleter::preprocessor_deleter(preprocessor_streambuf *buf,
preproc_map *defines,
std::vector<std::string> *callstack)
: std::basic_istream<char>(buf), buf_(buf), defines_(defines), callstack_(callstack), error_log(buf->error_log)
{
}
@ -931,6 +934,7 @@ preprocessor_deleter::~preprocessor_deleter()
rdbuf(NULL);
delete buf_;
delete defines_;
delete callstack_;
}
@ -952,6 +956,6 @@ std::istream *preprocess_file(std::string const &fname,
new preprocessor_file(*buf, callstack, fname);
if(error_log!=NULL&&error_log->empty()==false)
throw preproc_config::error("Error preprocessing files.");
return new preprocessor_deleter(buf, owned_defines);
return new preprocessor_deleter(buf, owned_defines,callstack);
}

View file

@ -45,6 +45,17 @@ metrics::metrics() : most_consecutive_requests_(0),
nrequests_waited_(0), started_at_(time(NULL))
{}
metrics::~metrics()
{
for(std::vector<sample>::iterator itor = samples_.begin();
itor != samples_.end(); ++itor)
{
delete[] itor->name.begin();
}
samples_.clear();
}
void metrics::service_request()
{
if(current_requests_ > 0) {

View file

@ -29,6 +29,7 @@ class metrics
{
public:
metrics();
~metrics();
void service_request();
void no_requests();