Uninitialized memory blocks in VC++

前端 未结 15 1307
鱼传尺愫
鱼传尺愫 2020-12-19 08:49

As everyone knows, the Visual C++ runtime marks uninitialized or just freed memory blocks with special non-zero markers. Is there any way to disable this behavior entirely w

15条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-19 09:13

    Why not create your own #define and get in the habit of using it?

    I.e.

    #define SafeDelete(mem) { delete mem; mem = NULL; }
    #define SafeDeleteArray(mem) { delete [] mem; mem = NULL; }

    Obviously you can name it whatever you like. deleteZ, deletesafe, whatever you're comfortable with.

提交回复
热议问题