K
kas
Hi Guys,
Do u see any memory leak issue with following code:-
bool myhook(
mem_if *pThis, .
char *Description
)
{
EXTMEMrange_t temp;
temp.name = new char[strlen(Description)+1]; <-allocation
strcpy(temp.name,Description);
....
....
bool result = AddRange(m_hkdMEMranges,temp);
return result;
}
bool AddRange(std::vector<EXTMEMrange_t> & rangeVector, EXTMEMrange_t
range)
{
....
delete [] range.name; <-deallocation
return true;
}
The temp is passed by value to function Addrange. temp.name is
allocated with new and deleted in Addrange.
Will shallow or deep copy can cause any issue here?
-KAS
Do u see any memory leak issue with following code:-
bool myhook(
mem_if *pThis, .
char *Description
)
{
EXTMEMrange_t temp;
temp.name = new char[strlen(Description)+1]; <-allocation
strcpy(temp.name,Description);
....
....
bool result = AddRange(m_hkdMEMranges,temp);
return result;
}
bool AddRange(std::vector<EXTMEMrange_t> & rangeVector, EXTMEMrange_t
range)
{
....
delete [] range.name; <-deallocation
return true;
}
The temp is passed by value to function Addrange. temp.name is
allocated with new and deleted in Addrange.
Will shallow or deep copy can cause any issue here?
-KAS