From: otto Date: Wed, 6 Jul 2016 20:32:02 +0000 (+0000) Subject: J/j is a three valued option, document and fix code to actuall support that X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=a6f029b1724cc6d4b09c7b9306f7cc71949c2836;p=openbsd J/j is a three valued option, document and fix code to actuall support that with a little help from jmc@ for the man page bits ok jca@ and a reluctant tedu@ --- diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c index 678c782d200..b4c0010f357 100644 --- a/lib/libc/stdlib/malloc.c +++ b/lib/libc/stdlib/malloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: malloc.c,v 1.191 2016/06/30 09:00:48 otto Exp $ */ +/* $OpenBSD: malloc.c,v 1.192 2016/07/06 20:32:02 otto Exp $ */ /* * Copyright (c) 2008, 2010, 2011 Otto Moerbeek * Copyright (c) 2012 Matthew Dempsky @@ -533,10 +533,12 @@ omalloc_parseopt(char opt) mopts.malloc_hint = 1; break; case 'j': - mopts.malloc_junk = 0; + if (mopts.malloc_junk > 0) + mopts.malloc_junk--; break; case 'J': - mopts.malloc_junk = 2; + if (mopts.malloc_junk < 2) + mopts.malloc_junk++; break; case 'n': case 'N': diff --git a/share/man/man5/malloc.conf.5 b/share/man/man5/malloc.conf.5 index e8e9a823d2c..6fe15cf353a 100644 --- a/share/man/man5/malloc.conf.5 +++ b/share/man/man5/malloc.conf.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: malloc.conf.5,v 1.6 2016/02/19 23:27:17 tb Exp $ +.\" $OpenBSD: malloc.conf.5,v 1.7 2016/07/06 20:32:02 otto Exp $ .\" .\" Copyright (c) 2012 Damien Miller .\" Copyright (c) 2008, 2009, 2010, 2011 Otto Moerbeek @@ -17,7 +17,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: February 19 2016 $ +.Dd $Mdocdate: July 6 2016 $ .Dt MALLOC.CONF 5 .Os .Sh NAME @@ -35,7 +35,8 @@ and finally looks at the global variable .Va malloc_options in the program. Each is scanned for the following flags. -Flags are single letters, uppercase means on, lowercase means off. +Flags are single letters. +Unless otherwise noted uppercase means on, lowercase means off. .Bl -tag -width indent .It Cm C .Dq Canaries . @@ -77,20 +78,23 @@ cause a segmentation fault upon any access. Pass a hint to the kernel about pages we don't use. If the machine is paging a lot this may help a bit. .It Cm J -.Dq Junk . -Fill some junk into the area allocated. +.Dq More junking . +Increase the junk level by one if it is smaller than 2. +.It Cm j +.Dq Less junking . +Decrease the junk level by one if it is larger than 0. +Junking writes some junk bytes into the area allocated. Currently junk is bytes of 0xd0 when allocating; this is pronounced .Dq Duh . \&:-) Freed chunks are filled with 0xdf. -.It Cm j -.Dq Don't Junk . -By default, small chunks are always junked, and the first part of pages -is junked after free. -The reuse of freed memory is delayed. -After the delay, the filling pattern is validated -and the process is aborted if the pattern was modified. -This option ensures that no junking is performed. +By default the junk level is 1: small chunks are always junked +and the first part of pages is junked after free. +After a delay (if not switched off by the F option), +the filling pattern is validated and the process is aborted if the pattern +was modified. +If the junk level is zero, no junking is performed. +For junk level 2, junking is done without size restrictions. .It Cm P .Dq Move allocations within a page. Allocations larger than half a page but smaller than a page