Click to See Complete Forum and Search --> : Map Stl
srisravi
May 25th, 2007, 02:11 AM
i have a map stl which goes like this---
map<String, int> *l_NetworkMap
i want to access the required m_Msisdn from the NetworkMap.
i have used find() and end() in this manner
map<string, int>::iterator pos;
pos = l_NetworkMap->find(string((char *)m_Msisdn));
if(l_NetworkMap.end() != pos)
{
......................................
/* remaining code */
}
but still i face a problem ..its core dump.
i am deriving this from a proc function which goes like this
refreshnetworkdetails((map<Str... int>) *m_arg)
where in i store all msisdns from the database into the NetworkMap.
RavensShadow
May 25th, 2007, 02:16 AM
whoops sorry, I didnt see that last little bit. What is the "..."?
Carlos Martinez
May 25th, 2007, 02:23 AM
i have a map stl which goes like this---
map<String, int> *l_NetworkMap
i want to access the required m_Msisdn from the NetworkMap.
i have used find() and end() in this manner
map<string, int>::iterator pos;
pos = l_NetworkMap->find(string((char *)m_Msisdn));
if(l_NetworkMap.end() != pos)
{
......................................
/* remaining code */
}
but still i face a problem ..its core dump.
i am deriving this from a proc function which goes like this
refreshnetworkdetails((map<Str... int>) *m_arg)
where in i store all msisdns from the database into the NetworkMap.
I see String and string types. I suppose to be a mistake when you write this example.
I don't see any other mistake, and i think the core is not a consecuence of the sencentes you write.
Have you analized the core dump for finding the concrete sentence that generates that core?
Have you seen what kind of core it is? (Segment violation, ....)
exterminator
May 25th, 2007, 03:28 AM
It will unless you actually create a map object. This - map<String, int> *l_NetworkMap - does not create the map object, just a pointer referring to I don't know what.
srisravi
May 25th, 2007, 05:54 AM
It will unless you actually create a map object. This - map<String, int> *l_NetworkMap - does not create the map object, just a pointer referring to I don't know what.
hi,
you are right.Its a pointer referring to networkmap into which all msisdns are inserted. i get this map when the application is up, to access it afterwards. when i want to check whether a particualr msisdn is present in that map or not...i want to use that find function.
And i dont want to change that MYSQL function which is as follows:
refreshBlackListDetails(map<string, int>* m_arg)
So how can i access those msisdns?
srisravi
May 25th, 2007, 06:15 AM
I see String and string types. I suppose to be a mistake when you write this example.
I don't see any other mistake, and i think the core is not a consecuence of the sencentes you write.
Have you analized the core dump for finding the concrete sentence that generates that core?
Have you seen what kind of core it is? (Segment violation, ....)
hi,
the application gives a core dump in the following manner:
Program terminated with signal 11, Segmentation fault.
Cannot access memory at address 0xb7600cc4
#0 0x080765dc in std::_Rb_tree<std::string, std::pair<std::string const, int>, std::_Select1st<std::pair<std::string const, int> >, std::less<std::string>, std::allocator<std::pair<std::string const, int> > >::find (this=Cannot access memory at address 0xb432e6d4
) at stl_tree.h:1267
1267 _Link_type __y = _M_header; // Last node which is not less than __k.
(gdb) bt
#0 0x080765dc in std::_Rb_tree<std::string, std::pair<std::string const, int>, std::_Select1st<std::pair<std::string const, int> >, std::less<std::string>, std::allocator<std::pair<std::string const, int> > >::find (this=Cannot access memory at address 0xb432e6d4
) at stl_tree.h:1267
Cannot access memory at address 0xb432e6cc
Paul McKenzie
May 25th, 2007, 01:09 PM
The error is as stated -- somewhere you are accessing invalid memory.
You posted 3 or 4 lines of code that doesn't really show us anything. There is no way you can get help with the such little information. Program crashes can only be diagnosed properly with the entire code being seen and run.
Regards,
Paul McKenzie
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.