Will this C++ code cause a memory leak (casting array new)

后端 未结 24 2984
暗喜
暗喜 2021-02-14 12:26

I have been working on some legacy C++ code that uses variable length structures (TAPI), where the structure size will depend on variable length strings. The structures are allo

24条回答
  •  甜味超标
    2021-02-14 13:00

    In addition to the excellent answers above, I would also like to add:

    If your code runs on linux or if you can compile it on linux then I would suggest running it through Valgrind. It is an excellent tool, among the myriad of useful warnings it produces it also will tell you when you allocate memory as an array and then free it as a non-array ( and vice-versa ).

提交回复
热议问题