0

C++ Memory Management is broken

I'm messing around with memory management in c++, but I got weird output. It doesn't say its an error or warning, it says free(): double free detected in tcache2. What does it mean? https://code.sololearn.com/coS0bmKqyRJ7/?ref=app

27th Jun 2020, 9:04 PM
Clueless Coder
Clueless Coder - avatar
2 Respuestas
+ 3
You are doing free and delete on ptr. free(ptr); delete ptr; Please remove one of them.
27th Jun 2020, 9:07 PM
$¢𝐎₹𝔭!𝐨𝓝
$¢𝐎₹𝔭!𝐨𝓝 - avatar
+ 2
Remove delete ptr; usually delete is used with new. And free with malloc and calloc.
27th Jun 2020, 9:09 PM
$¢𝐎₹𝔭!𝐨𝓝
$¢𝐎₹𝔭!𝐨𝓝 - avatar