Throughout various code, I have seen memory allocation in debug builds with NULL
...
memset(ptr,NULL,size);
Or with 0xDEA
I would go for NULL
because it's much easier to mass zero out memory than to go through later and set all the pointers to 0xDEADBEEF. In addition, there's nothing at all stopping 0xDEADBEEF from being a valid memory address on x86- admittedly, it would be unusual, but far from impossible. NULL
is more reliable.
Ultimately, look- NULL
is the language convention. 0xDEADBEEF just looks pretty and that's it. You gain nothing for it. Libraries will check for NULL
pointers, they don't check for 0xDEADBEEF pointers. In C++ then the idea of the zero pointer isn't even tied to a zero value, just indicated with the literal zero, and in C++0x there is a nullptr
and a nullptr_t
.