Euh non, NULL == 0 ou NULL == (void*)0, mais dans tous les cas NULL == 0, sinon dans le K&R, tous les cas de test de type if (!ptr) { ... } seraient à jeter.
Section 7.17 de la normel :
« NULL can be defined as any null pointer constant. Thus existing code can retain definitions of
NULL as 0 or 0L, but an implementation may also choose to define it as (void*)0. This latter
form of definition is convenient on architectures where sizeof(void*) does not equal the size
of any integer type. It has never been wise to use NULL in place of an arbitrary pointer as a
function 30 argument, however, since pointers to different types need not be the same size.
The library avoids this problem by providing special macros for the arguments to signal, the one
library function that might see a null function pointer. »
En pratique, POSIX demande que NULL == (void*)0 (désolé je n'ai pas le standard sous les yeux).
[^] # Re: Et pour ceux qui n'y connaissent rien...
Posté par lasher . En réponse au journal Un autre type de faille locale. Évalué à 1.
Section 7.17 de la normel :
« NULL can be defined as any null pointer constant. Thus existing code can retain definitions of
NULL as 0 or 0L, but an implementation may also choose to define it as (void*)0. This latter
form of definition is convenient on architectures where sizeof(void*) does not equal the size
of any integer type. It has never been wise to use NULL in place of an arbitrary pointer as a
function 30 argument, however, since pointers to different types need not be the same size.
The library avoids this problem by providing special macros for the arguments to signal, the one
library function that might see a null function pointer. »
En pratique, POSIX demande que NULL == (void*)0 (désolé je n'ai pas le standard sous les yeux).