Written yesterday Code After one day with the boss, I found the problem but did not solve it. Google and Baidu both found the answer.
Read the following code.
------------------------------
// Structure Definition
Typedef struct _ stru_cutpicinfo
{
String strcpurl; // address
String strmname; // The name of the clip.
Stru_cutpicinfo ()
{
Strmname = "";
Strcpurl = "";
};
} Stru_cutpicinfo, * lpstru_cutpicinfo;
Typedef STD: Map <int, stru_cutpicinfo> cutpic_list, * lpcutpic_list; // int -- Material ID
---------------------------------
// Fill
Cutpic_list m_adcutpiclist;
M_mapcs.lock ();
If (asxmsginfo. m_adcutpiclist.size () <3)
{
Stru_cutpicinfo lcpinfo;
Lcpinfo. strcpurl = videoaditem. mstrcutpicurl;
Lcpinfo. strmname = videoaditem. stritemname;
Asxmsginfo. m_adcutpiclist.insert (make_pair (liadid, lcpinfo ));
}
M_mapcs.unlock ();
--------------------------------------------------
Then, send a message to the control.
Sendmessage (...,..., (wparam) (lpvoid) & m_adcutpiclist ,...);
---------------------------
After receiving the message
Cutpic_list * mpcplist = (cutpiclist *) (lpvoid) aparam; // here, aparam is the address of the map structure.
Cutpic_list: iterator itr = mpcplist-> begin ();
While (itr! = Mpcplist-> end ())
{
Int IID = itr-> first;
String strurl = itr-> second. strcpurl;
String strname = itr-> second. strmname;
++ Itr;
}
well, let's talk about the error. In the while loop, the data can be read out in the first round. After the iterator increases,
it is found that the iterator points to an empty position, memory leakage. I checked a lot of information and couldn't solve the problem.
finally, I switched map to vector, which solved this weird problem. Does map iterator have some restrictions or rules?
I hope my friends who have encountered this problem can help me find out what the problem is.