Browse Source

move allocations between half a page and a page as close to the end of

the page as possible (i.e. make malloc option P a default).
ok art@ millert@ krw@
OPENBSD_4_5
otto 16 years ago
parent
commit
5b2827b23a
2 changed files with 5 additions and 4 deletions
  1. +3
    -2
      src/lib/libc/stdlib/malloc.3
  2. +2
    -2
      src/lib/libc/stdlib/malloc.c

+ 3
- 2
src/lib/libc/stdlib/malloc.3 View File

@ -30,9 +30,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: malloc.3,v 1.56 2008/11/02 14:42:01 otto Exp $
.\" $OpenBSD: malloc.3,v 1.57 2008/11/20 09:05:15 otto Exp $
.\" .\"
.Dd $Mdocdate: November 2 2008 $
.Dd $Mdocdate: November 20 2008 $
.Dt MALLOC 3 .Dt MALLOC 3
.Os .Os
.Sh NAME .Sh NAME
@ -254,6 +254,7 @@ Freed chunks are filled with 0xdf.
Allocations larger than half a page but smaller that a page Allocations larger than half a page but smaller that a page
are aligned to the end of a page to catch buffer overruns in more are aligned to the end of a page to catch buffer overruns in more
cases. cases.
This is the default.
.It Cm R .It Cm R
.Dq realloc . .Dq realloc .
Always reallocate when Always reallocate when


+ 2
- 2
src/lib/libc/stdlib/malloc.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: malloc.c,v 1.109 2008/11/20 09:01:24 otto Exp $ */
/* $OpenBSD: malloc.c,v 1.110 2008/11/20 09:05:15 otto Exp $ */
/* /*
* Copyright (c) 2008 Otto Moerbeek <otto@drijf.net> * Copyright (c) 2008 Otto Moerbeek <otto@drijf.net>
* *
@ -154,7 +154,7 @@ static int malloc_active; /* status of malloc */
static int malloc_freeprot; /* mprotect free pages PROT_NONE? */ static int malloc_freeprot; /* mprotect free pages PROT_NONE? */
static int malloc_hint; /* call madvice on free pages? */ static int malloc_hint; /* call madvice on free pages? */
static int malloc_junk; /* junk fill? */ static int malloc_junk; /* junk fill? */
static int malloc_move; /* move allocations to end of page? */
static int malloc_move = 1; /* move allocations to end of page? */
static int malloc_realloc; /* always realloc? */ static int malloc_realloc; /* always realloc? */
static int malloc_xmalloc; /* xmalloc behaviour? */ static int malloc_xmalloc; /* xmalloc behaviour? */
static int malloc_zero; /* zero fill? */ static int malloc_zero; /* zero fill? */


Loading…
Cancel
Save