Is it necessary to call delete[] vs delete for char arrays?

前端 未结 3 2002

I\'m utilizing a library written by a collegue and discovered that valgrind was spewing out errors related to the delete.

The problem was t

3条回答
  •  醉梦人生
    2021-01-12 08:29

    Forget about destructors. The difference between new/delete and new[]/delete[] is that these are two completely unrelated, independent memory allocation mechanisms. They cannot be mixed. Using delete to deallocate memory allocated with new[] is no different than using free for the same purpose.

提交回复
热议问题