I have the following code:
Data* t = (Data*)(malloc(len_part_ * sizeof(Data)));
memcpy(t, data_[i], len_temp_ * sizeof(Data));
std::swap(t, data_[i]);
free(t);
The problem is that "A heap has been corrupted" error occruing sometimes in free(t)
. At these times parameters are:
sizeof(Data) = 8;
len_part_ = 24;
len_temp_ = 8;
Info:
data_
field is Data**
while Data
defined as typedef std::pair<int,int> Data;