[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Pointer if test for for NULL
- Date: Thu, 29 Apr 2010 11:39:30 +1000
- From: chrisj at rtems.org (Chris Johns)
- Subject: Pointer if test for for NULL
The Austin Group (Open Group) has been having a discussion about NULL
meaning all bits 0 . For example:
struct s* p;
p = malloc (sizeof (struct s));
memset (p, 0, sizeof (*p));
The issue raised is "If 'struct s' contains a pointer is the pointer
initialised to NULL correctly ?". This is not what I wish to discuss.
Considering this I am wondering if the 'if (p)' code is strictly valid ?
Does this code also imply false happens if NULL is all bits 0 ?
Should this code be changed to:
if (p != NULL)
I am guilty of coding the if's this way and I am wondering if this
should be changed.