summaryrefslogtreecommitdiff
path: root/src/lib/libc
diff options
context:
space:
mode:
authorschwarze <>2025-05-27 12:40:37 +0000
committerschwarze <>2025-05-27 12:40:37 +0000
commit96e3ac7e0e578559ab5be5b73c15e2a15f043994 (patch)
treee10609633c9661306371ef9a8817c35487ce13b5 /src/lib/libc
parent01105d6b069e4487ba98919cf479be7cdc0526a2 (diff)
downloadopenbsd-96e3ac7e0e578559ab5be5b73c15e2a15f043994.tar.gz
openbsd-96e3ac7e0e578559ab5be5b73c15e2a15f043994.tar.bz2
openbsd-96e3ac7e0e578559ab5be5b73c15e2a15f043994.zip
Delete bad advice about abusing malloc_options = "X" as a production
feature to terminate the program when out of memory. Application code should always handle failure of library functions properly. So if you want your program to terminate, write something like | p = malloc(...); | if (p == NULL) | err(1, NULL); and don't abuse malloc_options. Direction suggested by otto@ after anton@ pointed out that this very old text still used an outdated data type for malloc_options and potentially failed to define its value at compile time. OK otto@
Diffstat (limited to 'src/lib/libc')
-rw-r--r--src/lib/libc/stdlib/malloc.315
1 files changed, 3 insertions, 12 deletions
diff --git a/src/lib/libc/stdlib/malloc.3 b/src/lib/libc/stdlib/malloc.3
index 361fbe4d1d..74e89d7fde 100644
--- a/src/lib/libc/stdlib/malloc.3
+++ b/src/lib/libc/stdlib/malloc.3
@@ -30,9 +30,9 @@
30.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31.\" SUCH DAMAGE. 31.\" SUCH DAMAGE.
32.\" 32.\"
33.\" $OpenBSD: malloc.3,v 1.144 2025/05/24 12:47:11 schwarze Exp $ 33.\" $OpenBSD: malloc.3,v 1.145 2025/05/27 12:40:37 schwarze Exp $
34.\" 34.\"
35.Dd $Mdocdate: May 24 2025 $ 35.Dd $Mdocdate: May 27 2025 $
36.Dt MALLOC 3 36.Dt MALLOC 3
37.Os 37.Os
38.Sh NAME 38.Sh NAME
@@ -372,18 +372,9 @@ Use with
372to get a verbose dump of malloc's internal state. 372to get a verbose dump of malloc's internal state.
373.It Cm X 373.It Cm X
374.Dq xmalloc . 374.Dq xmalloc .
375Rather than return failure, 375Rather than return failure to handle out-of-memory conditions gracefully,
376.Xr abort 3 376.Xr abort 3
377the program with a diagnostic message on stderr. 377the program with a diagnostic message on stderr.
378It is the intention that this option be set at compile time by
379including in the source:
380.Bd -literal -offset indent
381extern char *malloc_options;
382malloc_options = "X";
383.Ed
384.Pp
385Note that this will cause code that is supposed to handle
386out-of-memory conditions gracefully to abort instead.
387.It Cm < 378.It Cm <
388.Dq Halve the cache size . 379.Dq Halve the cache size .
389Decrease the size of the free page cache by a factor of two. 380Decrease the size of the free page cache by a factor of two.