0xDEADBEEF vs. NULL

后端 未结 10 1622
醉梦人生
醉梦人生 2020-12-13 14:45

Throughout various code, I have seen memory allocation in debug builds with NULL...

memset(ptr,NULL,size);

Or with 0xDEA

10条回答
  •  心在旅途
    2020-12-13 14:59

    I would personally recommend using NULL (or 0x0) as it represents the NULL as expected and comes in handy while comparison. Imagine you are using char * and in between on DEADBEEF for some reason (don't know why), then at least your debugger will come very handy to tell you that its 0x0.

提交回复
热议问题