|
See the Remarks section here[^].
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
VCProgrammer wrote: obj_Per->age = "35";
Isn't the age member an int ?
VCProgrammer wrote: If i want to find item with particular ID then how can i do this??
At this point, I'd be more concerned with adding an item properly. obj_Per has not been initialized (for each item).
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Well spotted, I failed to notice that.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
you can use GetAt function Gets the element at a given position.
please look for the MSDN CList member function
|
|
|
|
|
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:
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 ) );
std::vector<std::string> tokens;
mrpt::system::tokenize( aux,"[], \t",tokens);
if (tokens.size()==0)
{
outValues = defaultValue;
}
else
{
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];
}
}
}
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;
}
}
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 );
}
m_reacNavObj->loadConfigFile(
*m_iniReactive,
*m_configRobotIni );
}
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!!!
|
|
|
|
|
Fred Ackers wrote: 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?
there's one candidate!
and, in general, you have to be very careful about passing STL objects across DLL boundaries.
http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q172396[^]
|
|
|
|
|
I posted a reply to another in the thread with more information. It is sounding to me like I have a lot of work to get this library to compile with mine though due to the differences in linking with the core c++ libraries. Would you say that is an accurate statement?
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!!!
|
|
|
|
|
Fred Ackers wrote: Would you say that is an accurate statement?
unfortunately, yes.
in general, exporting C++ objects across DLL boundaries is dangerous because you run the risk of creating an object with one version of the C++/CRT and deleting it with another.
|
|
|
|
|
I set all my libraries finally to use attempt to use the same version of the linking. Although I did have to set the compiler option of /FORCE:MULTIPLE. And that fixed the problem with the heap error. True, I discover other errors. But my initial problem is now fixed. Thanks.
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!!!
|
|
|
|
|
"a heap error on the deletion of the std::vector tokens"
I cant see any deletion of anything called tokens but in anycase, you dont want to delete a stack variable. It gets cleaned up when the func exits. You only delete stuff you have allocated with new.
==============================
Nothing to say.
|
|
|
|
|
Run app verifier on it. It looks s if the heap vector is getting corrupted somehow.
==============================
Nothing to say.
|
|
|
|
|
I was able to solve the problem by setting all of the libraries to use multi-threaded dll instead of some multi-threaded and others multi-threaded dll. I had to use the /FORCE:MULTIPLE option but it works now without a heap error. Question though: Where do I find this app verifier you mentioned?
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!!!
|
|
|
|
|
Application Verifier is a Microsoft download. You can get it of MSDN
==============================
Nothing to say.
|
|
|
|
|
In Win32, when you pass an object through DLL boundaries you cannot allocate memory in one module (DLL) and delete it in another module (your main program, another DLL), unless you use the Global Heap for allocation/deallocation. Another approach is to create a deallocator function in the same module and pass it to another module to delete the object.
In Win64, there will be no problem: you can allocate objects in one module and delete them in another.
|
|
|
|
|
hi all,
i have hexadecimal values in the form of CString in my list control.
i want to sort them and my list according to those sorted values.
How can i do this??
|
|
|
|
|
If they are strings then you can use a simple string comparison.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Simple String Comparison will lead to dictionary type sorting. OP would also have to verify the length of string
as example
ABE
AB
ACD
ABEF
If you sort simply comparing string then the output will be look like
AB
ABE
ABEF
ACD
But If you do sorting(mathematical) Then it would be
AB
ABE
ACD
ABEF
So, I will suggest to consider the length of the string too
|
|
|
|
|
You may use your custom sorting function in ListView_SortItemsEx[^] call.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi,
what is difference between windows 7 and windows 2003 sever in memory heap allocation?
i have a project in visual studio 2008 C++ with using Unicode for character setting.
my project run in 2003 sever without any problem. but when i run it in windows 7, my project is breaked on a "memory allocation" line in code, like:
int i_size = 50;
wchar_t* wch = new wchar_t[i_size];
with this error message:
this maybe due to a corruption of the heap, which indicate a bug in my.exe or any of the Dlls it has loaded.
please help me.
Zo.Naderi-Iran
|
|
|
|
|
This means that the heap has been corrupted somewhere else in your code. you will need to do some debugging to discover where it happens; usually caused by overrunning a buffer somewhere.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
but my project compile and run in windows 2003 sever without any heap corruption!
what difference between windows 2003 and windows 7 ?
Zo.Naderi-Iran
|
|
|
|
|
Different is Windows 7 is giving you better security(probably)
Here is an example of how heap crashed
In one of my application I defined a string variable with the size of 20, I was reading the text from a text box. But User Put more than 20 character in that box.
It never crash in xp. But Do worse it destroy another value which has been defined right after that sting variable.
So, Its better it crashed cause at least you know where you can find the problem
|
|
|
|
|
i guess that my problem is not in size of memory allocation. However, i will check it.
but, is any other reason?
Zo.Naderi-Iran
|
|
|
|
|
zon_cpp wrote: is any other reason?
Such as what? If the heap is corrupted that means there is a piece of code that is writing somewhere in memory at an address that it does not own - it's a bug.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Just because it runs successfully in one system does not mean it is bug free. If it crashes because of heap corruption it is almost guaranteed that there is a bug in your code somewhere.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|