From 96e3ac7e0e578559ab5be5b73c15e2a15f043994 Mon Sep 17 00:00:00 2001 From: schwarze <> Date: Tue, 27 May 2025 12:40:37 +0000 Subject: 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@ --- src/lib/libc/stdlib/malloc.3 | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'src/lib/libc') 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 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $OpenBSD: malloc.3,v 1.144 2025/05/24 12:47:11 schwarze Exp $ +.\" $OpenBSD: malloc.3,v 1.145 2025/05/27 12:40:37 schwarze Exp $ .\" -.Dd $Mdocdate: May 24 2025 $ +.Dd $Mdocdate: May 27 2025 $ .Dt MALLOC 3 .Os .Sh NAME @@ -372,18 +372,9 @@ Use with to get a verbose dump of malloc's internal state. .It Cm X .Dq xmalloc . -Rather than return failure, +Rather than return failure to handle out-of-memory conditions gracefully, .Xr abort 3 the program with a diagnostic message on stderr. -It is the intention that this option be set at compile time by -including in the source: -.Bd -literal -offset indent -extern char *malloc_options; -malloc_options = "X"; -.Ed -.Pp -Note that this will cause code that is supposed to handle -out-of-memory conditions gracefully to abort instead. .It Cm < .Dq Halve the cache size . Decrease the size of the free page cache by a factor of two. -- cgit v1.2.3-55-g6feb