mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-20 15:48:05 +03:00
Use boost::scoped_ptr to avoid resource leaks.
This commit is contained in:
parent
c8800f3822
commit
5c4e2a8c8d
@ -9,6 +9,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include <getopt.h>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
#include "Data.h"
|
||||
#include "Scorer.h"
|
||||
@ -185,7 +186,8 @@ int main(int argc, char** argv)
|
||||
|
||||
TRACE_ERR("Scorer type: " << option.scorerType << endl);
|
||||
|
||||
Scorer* scorer = ScorerFactory::getScorer(option.scorerType, option.scorerConfig);
|
||||
boost::scoped_ptr<Scorer> scorer(
|
||||
ScorerFactory::getScorer(option.scorerType, option.scorerConfig));
|
||||
|
||||
scorer->setFactors(option.scorerFactors);
|
||||
|
||||
@ -218,8 +220,6 @@ int main(int argc, char** argv)
|
||||
data.save(option.featureDataFile, option.scoreDataFile, option.binmode);
|
||||
PrintUserTime("Stopping...");
|
||||
|
||||
delete scorer;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
} catch (const exception& e) {
|
||||
cerr << "Exception: " << e.what() << endl;
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <ctime>
|
||||
|
||||
#include <getopt.h>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
#include "Data.h"
|
||||
#include "Point.h"
|
||||
@ -333,17 +334,18 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
// it make sense to know what parameter set were used to generate the nbest
|
||||
Scorer *TheScorer = ScorerFactory::getScorer(option.scorer_type, option.scorer_config);
|
||||
boost::scoped_ptr<Scorer> scorer(
|
||||
ScorerFactory::getScorer(option.scorer_type, option.scorer_config));
|
||||
|
||||
//load data
|
||||
Data data(*TheScorer);
|
||||
Data data(*scorer);
|
||||
|
||||
for (size_t i = 0; i < ScoreDataFiles.size(); i++) {
|
||||
cerr<<"Loading Data from: "<< ScoreDataFiles.at(i) << " and " << FeatureDataFiles.at(i) << endl;
|
||||
data.load(FeatureDataFiles.at(i), ScoreDataFiles.at(i));
|
||||
}
|
||||
|
||||
TheScorer->setScoreData(data.getScoreData().get());
|
||||
scorer->setScoreData(data.getScoreData().get());
|
||||
|
||||
//ADDED_BY_TS
|
||||
data.remove_duplicates();
|
||||
@ -506,7 +508,6 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
delete TheScorer;
|
||||
PrintUserTime("Stopping...");
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user