Click here to Skip to main content
15,890,741 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to Delete A Node with its all Child in XML File ? Pin
CPallini22-Dec-11 23:40
mveCPallini22-Dec-11 23:40 
AnswerRe: How to Delete A Node with its all Child in XML File ? Pin
jschell23-Dec-11 10:01
jschell23-Dec-11 10:01 
QuestionFinding an item in linked list (CList) Pin
VCProgrammer22-Dec-11 19:00
VCProgrammer22-Dec-11 19:00 
AnswerRe: Finding an item in linked list (CList) Pin
Richard MacCutchan22-Dec-11 22:45
mveRichard MacCutchan22-Dec-11 22:45 
SuggestionRe: Finding an item in linked list (CList) Pin
David Crow23-Dec-11 3:35
David Crow23-Dec-11 3:35 
GeneralRe: Finding an item in linked list (CList) Pin
Richard MacCutchan23-Dec-11 4:46
mveRichard MacCutchan23-Dec-11 4:46 
AnswerRe: Finding an item in linked list (CList) Pin
smileangle27-Dec-11 13:37
smileangle27-Dec-11 13:37 
QuestionHeap error on std::string deletion from local function Pin
Fred Ackers22-Dec-11 1:04
Fred Ackers22-Dec-11 1:04 
I am developing using the MRPT ReactiveNavigationDemo app. I have put the core of the demo inside a dll, and use the dll to call the mrpt library. I then call the dll from the main application. Everything works fine except for one function. The read_vector function from the CConfigFileBase causes a heap error on the deletion of the std::vector tokens within the function. I have been unable to locate the source of the function. I tried to move the tokens to be a class variable instead and when I do, it says that the tokenize function does have valid parameters even though all I chaged was the std::vector tokens from a local variable to a class one. I also tried make the vector a deque instead and still receive the same error. I have undone the changes and still get the same error. I have tried to look on the web for help and no success there. The tokenize portion is properly storing the variables in the vector passed to it, it is just the deletion of any local variables that is causing the problem. My main library is /MTd and the mrpt base is /MDd. Not sure if that makes a difference or not. Any ideas as to what may be causing the error? Is this a problem with the function itself? Or am I missing something somewhere? I have already asked some time ago on the forums for the library with no response. I am hoping someone here will be able to provide me with the insight I am lacking. Thanks. I have included my code below:

C++
//CConfigFileBase Function

 

template <class VECTOR_TYPE>
void  read_vector(
const std::string  & section,
const std::string  & name,
const VECTOR_TYPE  & defaultValue,
VECTOR_TYPE        & outValues,
bool                 failIfNotFound = false) const
{
   std::string aux ( readString(section, name, "",failIfNotFound ) );
   // Parse the text into a vector:
   std::vector<std::string> tokens;
   mrpt::system::tokenize( aux,"[], \t",tokens);
 
   if (tokens.size()==0)
   {
      outValues = defaultValue;
   }
   else
   {
      // Parse to numeric type:
      const size_t N = tokens.size();
      outValues.resize( N );
      for (size_t i=0;i<N;i++)
      {
          std::stringstream ss(tokens[i]);
          ss >> outValues[i];
      }
   }
}

//DLL Library Function
ReloadRobotShape(vector<float> &xs, vector<float>& ys, string &robotNameUsedInConfigFile)
{
   try
   {
       string robotName = m_configRobotIni->read_string("ROBOT_NAME","Name",robotNameUsedInConfigFile);
 
       vector<float> tempXS, tempYS;
       vector<float> type(0);
       string xsName = "RobotModel_shape2D_xs";
       string ysName = "RobotModel_shape2D_ys";
       if (m_iniReactive->sectionExists(robotName))
       {
           m_iniReactive->read_vector(robotName,xsName,type, tempXS, true );
           m_iniReactive->read_vector(robotName,ysName,type, tempYS, true );
 
           xs = tempXS;
           ys = tempYS;
       }
   }
   catch( std::exception & e)
   {
      cout << e.what() << endl;
      cerr << e.what() << endl;
   }
}
//DLL Library Function
LoadConfigFiles(string &reactiveIni, string &robotIni, bool isMemoryStringInsteadOfFile)
{
    if (isMemoryStringInsteadOfFile)
    {
        m_iniReactive = new CConfigFileMemory( reactiveIni );
        m_configRobotIni = new CConfigFileMemory( robotIni );
    }
    else
    {
        m_iniReactive = new CConfigFile( reactiveIni );
        m_configRobotIni = new CConfigFile( robotIni );
    }
    // Reload config:
    m_reacNavObj->loadConfigFile(
        *m_iniReactive,
        *m_configRobotIni );
}
 
//Main Application Function
reloadRobotShape()
{
    try
    {
        vector<float> xs,ys;
        string robotName = "SENA";
        m_lamps->LoadConfigFiles(EDIT_internalCfgReactive,EDIT_internalCfgRobot,true);
        m_lamps->ReloadRobotShape(xs,ys,robotName);
 
        lyVehicle->setPoints(xs,ys,true);
    }
    catch( std::exception & e)
    {
        cout << e.what() << endl;
        cerr << e.what() << endl;
    }
}

Nothing is impossible, It's merely a matter of finding an answer to the question of HOW? ... And answering that question is usually the most difficult part of the job!!!

AnswerRe: Heap error on std::string deletion from local function Pin
Chris Losinger22-Dec-11 1:34
professionalChris Losinger22-Dec-11 1:34 
GeneralRe: Heap error on std::string deletion from local function Pin
Fred Ackers22-Dec-11 9:33
Fred Ackers22-Dec-11 9:33 
GeneralRe: Heap error on std::string deletion from local function Pin
Chris Losinger22-Dec-11 9:55
professionalChris Losinger22-Dec-11 9:55 
GeneralRe: Heap error on std::string deletion from local function Pin
Fred Ackers22-Dec-11 10:44
Fred Ackers22-Dec-11 10:44 
AnswerRe: Heap error on std::string deletion from local function Pin
Erudite_Eric22-Dec-11 4:28
Erudite_Eric22-Dec-11 4:28 
AnswerRe: Heap error on std::string deletion from local function Pin
Erudite_Eric23-Dec-11 23:48
Erudite_Eric23-Dec-11 23:48 
GeneralRe: Heap error on std::string deletion from local function Pin
Fred Ackers24-Dec-11 7:16
Fred Ackers24-Dec-11 7:16 
GeneralRe: Heap error on std::string deletion from local function Pin
Erudite_Eric26-Dec-11 0:57
Erudite_Eric26-Dec-11 0:57 
AnswerRe: Heap error on std::string deletion from local function Pin
Mikhail Semenov23-Jan-12 3:50
Mikhail Semenov23-Jan-12 3:50 
Questionsorting list using hexadecimal values Pin
VCProgrammer21-Dec-11 21:20
VCProgrammer21-Dec-11 21:20 
AnswerRe: sorting list using hexadecimal values Pin
Richard MacCutchan21-Dec-11 22:00
mveRichard MacCutchan21-Dec-11 22:00 
GeneralRe: sorting list using hexadecimal values Pin
Mohibur Rashid21-Dec-11 22:26
professionalMohibur Rashid21-Dec-11 22:26 
AnswerRe: sorting list using hexadecimal values Pin
CPallini21-Dec-11 22:50
mveCPallini21-Dec-11 22:50 
Questioncrash in memory heap allocation - windows 7 - Unicode project Pin
zon_cpp21-Dec-11 21:04
zon_cpp21-Dec-11 21:04 
AnswerRe: crash in memory heap allocation - windows 7 - Unicode project Pin
Richard MacCutchan21-Dec-11 22:05
mveRichard MacCutchan21-Dec-11 22:05 
GeneralRe: crash in memory heap allocation - windows 7 - Unicode project Pin
zon_cpp21-Dec-11 22:08
zon_cpp21-Dec-11 22:08 
GeneralRe: crash in memory heap allocation - windows 7 - Unicode project Pin
Mohibur Rashid21-Dec-11 22:31
professionalMohibur Rashid21-Dec-11 22:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.