diff options
author | Alejandro Colomar <alx.manpages@gmail.com> | 2022-09-09 14:15:08 +0200 |
---|---|---|
committer | Alejandro Colomar <alx.manpages@gmail.com> | 2022-09-09 14:15:08 +0200 |
commit | 96e72ec1fbadd13cbcbc2b263540e4f5e9e09d7c (patch) | |
tree | 70686b943e33a6e939ad265acb7ddfef70b91f32 /man3const | |
parent | 8f4ed6463206e8ede815c72085c7305dafc2e4fc (diff) |
Revert "src.mk, All pages: Move man* to man/"
This reverts commit 70ac1c4785fc1e158ab2349a962dba2526bf4fbc.
Link: <https://lore.kernel.org/linux-man/YxcV4h+Xn7cd6+q2@pevik/T/>
Reported-by: Petr Vorel <pvorel@suse.cz>
Reported-by: Jakub Wilk <jwilk@jwilk.net>
Cc: Stefan Puiu <stefan.puiu@gmail.com>
Signed-off-by: Alex Colomar <alx.manpages@gmail.com>
Diffstat (limited to 'man3const')
-rw-r--r-- | man3const/NULL.3const | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/man3const/NULL.3const b/man3const/NULL.3const new file mode 100644 index 000000000..68bc7839d --- /dev/null +++ b/man3const/NULL.3const @@ -0,0 +1,74 @@ +.\" Copyright (c) 2022 by Alejandro Colomar <colomar.6.4.3@gmail.com> +.\" +.\" SPDX-License-Identifier: Linux-man-pages-copyleft +.\" +.\" +.TH NULL 3const 2022-07-22 "Linux man-pages (unreleased)" +.SH NAME +NULL \- null pointer constant +.SH LIBRARY +Standard C library +.RI ( libc ) +.SH SYNOPSIS +.nf +.B #include <stddef.h> +.PP +.B "#define NULL ((void *) 0)" +.fi +.SH DESCRIPTION +.B NULL +represents a null pointer constant, +that is, a pointer that does not point to anything. +.SH CONFORMING TO +C99 and later; +POSIX.1-2001 and later. +.SH NOTES +The following headers also provide +.BR NULL : +.IR <locale.h> , +.IR <stdio.h> , +.IR <stdlib.h> , +.IR <string.h> , +.IR <time.h> , +.IR <unistd.h> , +and +.IR <wchar.h> . +.SH CAVEATS +It is undefined behavior to dereference a null pointer, +and that usually causes a segmentation fault in practice. +.PP +It is also undefined behavior to perform pointer arithmetic on it. +.PP +.I NULL \- NULL +is undefined behavior, according to ISO C, but is defined to be 0 in C++. +.PP +To avoid confusing human readers of the code, +do not compare pointer variables to +.BR 0 , +and do not assign +.B 0 +to them. +Instead, always use +.BR NULL . +.PP +.B NULL +shouldn't be confused with +.BR NUL , +which is an +.BR ascii (7) +character, +represented in C as +.BR \(aq\e0\(aq . +.SH BUGS +When it is necessary to set a pointer variable to a null pointer, +it is not enough to use +.BR memset (3) +to zero the pointer +(this is usually done when zeroing a struct that contains pointers), +since ISO C and POSIX don't guarantee that a bit pattern of all 0s +represent a null pointer. +See the EXAMPLES section in +.BR getaddrinfo (3) +for an example program that does this correctly. +.SH SEE ALSO +.BR void (3type) |