vendredi 14 décembre 2018

How to solve Memory leak for boost program options

I am using following boost program options

1 #include <boost/program_options.hpp>
2 using namespace boost::program_options;

3 #include <iostream>
4 using namespace std;

5 /* Auxiliary functions for checking input for validity. */


 6 int main(int argc, char* argv[])
 7 {
 8   try {
 9      string ofile;
 10       string macrofile, libmakfile;
 11       bool t_given = false;
 12       bool b_given = false;
 13       string mainpackage;
 14       string depends = "deps_file";
 15       string sources = "src_file";
 16      string root = ".";

 17       options_description desc("Allowed options");
 18     desc.add_options()
       // First parameter describes option name/short name
       // The second is parameter to option
       // The third is description
 19      ("help,h", "print usage message")
 20     ("output,o", value(&ofile), "pathname for output")
 21      ("macrofile,m", value(&macrofile), "full pathname of macro.h")
               ;

 22 } 
 23 }             



I am using   gcc-5.4.0-static and I am getting memory leak error

Memory leak. Dynamic memory stored in 'po::value > ( &i _ofile)' allocated through function 'value,std::allocator >,std::allocator,std::allocator > > > >' at line line 20 is lost at line end of (22) line

Aucun commentaire:

Enregistrer un commentaire