Hi,

J/j is actually a three valued var. So document that and make it
possible to set all three values. Default is still 1.

        -Otto

Index: share/man/man5/malloc.conf.5
===================================================================
RCS file: /cvs/src/share/man/man5/malloc.conf.5,v
retrieving revision 1.6
diff -u -p -r1.6 malloc.conf.5
--- share/man/man5/malloc.conf.5        19 Feb 2016 23:27:17 -0000      1.6
+++ share/man/man5/malloc.conf.5        2 Jul 2016 08:36:19 -0000
@@ -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 acce
 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
Index: lib/libc/stdlib/malloc.c
===================================================================
RCS file: /cvs/src/lib/libc/stdlib/malloc.c,v
retrieving revision 1.191
diff -u -p -r1.191 malloc.c
--- lib/libc/stdlib/malloc.c    30 Jun 2016 09:00:48 -0000      1.191
+++ lib/libc/stdlib/malloc.c    2 Jul 2016 08:36:19 -0000
@@ -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':

Reply via email to