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 RĂ©ponses
+ 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