Browse Source

introduce symbolic constant for initial number of regions

OPENBSD_5_0
otto 13 years ago
parent
commit
535636b5df
1 changed files with 3 additions and 2 deletions
  1. +3
    -2
      src/lib/libc/stdlib/malloc.c

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

@ -1,4 +1,4 @@
/* $OpenBSD: malloc.c,v 1.135 2011/05/18 18:07:20 otto Exp $ */
/* $OpenBSD: malloc.c,v 1.136 2011/05/18 18:09:37 otto Exp $ */
/* /*
* Copyright (c) 2008 Otto Moerbeek <otto@drijf.net> * Copyright (c) 2008 Otto Moerbeek <otto@drijf.net>
* *
@ -67,6 +67,7 @@
#define MALLOC_MAXCHUNK (1 << MALLOC_MAXSHIFT) #define MALLOC_MAXCHUNK (1 << MALLOC_MAXSHIFT)
#define MALLOC_MAXCACHE 256 #define MALLOC_MAXCACHE 256
#define MALLOC_DELAYED_CHUNKS 15 /* max of getrnibble() */ #define MALLOC_DELAYED_CHUNKS 15 /* max of getrnibble() */
#define MALLOC_INITIAL_REGIONS 512
/* /*
* When the P option is active, we move allocations between half a page * When the P option is active, we move allocations between half a page
* and a whole page towards the end, subject to alignment constraints. * and a whole page towards the end, subject to alignment constraints.
@ -603,7 +604,7 @@ omalloc_init(struct dir_info **dp)
d = (struct dir_info *)(p + MALLOC_PAGESIZE + d = (struct dir_info *)(p + MALLOC_PAGESIZE +
(arc4random_uniform(d_avail) << MALLOC_MINSHIFT)); (arc4random_uniform(d_avail) << MALLOC_MINSHIFT));
d->regions_free = d->regions_total = 512;
d->regions_free = d->regions_total = MALLOC_INITIAL_REGIONS;
regioninfo_size = d->regions_total * sizeof(struct region_info); regioninfo_size = d->regions_total * sizeof(struct region_info);
d->r = MMAP(regioninfo_size); d->r = MMAP(regioninfo_size);
if (d->r == MAP_FAILED) { if (d->r == MAP_FAILED) {


Loading…
Cancel
Save