diff options
author | jasone <jasone@FreeBSD.org> | 2008-01-03 23:22:13 +0000 |
---|---|---|
committer | jasone <jasone@FreeBSD.org> | 2008-01-03 23:22:13 +0000 |
commit | 6aea4f4c16b4f978f61b66893221b994c8bc83bc (patch) | |
tree | 0b05b1800e37ac661aad0283426f69cde4456735 /lib/libc/stdlib/malloc.c | |
parent | a6857bc34c4b3f2afc101f15a0f4093000e89460 (diff) | |
download | FreeBSD-src-6aea4f4c16b4f978f61b66893221b994c8bc83bc.zip FreeBSD-src-6aea4f4c16b4f978f61b66893221b994c8bc83bc.tar.gz |
Enable both sbrk(2)- and mmap(2)-based memory acquisition methods by
default. This has the disadvantage of rendering the datasize resource
limit irrelevant, but without this change, legitimate uses of more
memory than will fit in the data segment are thwarted by default.
Fix chunk_alloc_mmap() to work correctly if initial mapping is not
chunk-aligned and mapping extension fails.
Diffstat (limited to 'lib/libc/stdlib/malloc.c')
-rw-r--r-- | lib/libc/stdlib/malloc.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c index 5c987c5..abe367a 100644 --- a/lib/libc/stdlib/malloc.c +++ b/lib/libc/stdlib/malloc.c @@ -1,5 +1,5 @@ /*- - * Copyright (C) 2006,2007 Jason Evans <jasone@FreeBSD.org>. + * Copyright (C) 2006-2008 Jason Evans <jasone@FreeBSD.org>. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -131,7 +131,7 @@ * unnecessary, but we are burdened by history and the lack of resource limits * for anonymous mapped memory. */ -#define MALLOC_DSS +#define MALLOC_DSS #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); @@ -821,7 +821,7 @@ static bool opt_junk = false; #endif #ifdef MALLOC_DSS static bool opt_dss = true; -static bool opt_mmap = false; +static bool opt_mmap = true; #endif static bool opt_hint = false; #ifdef MALLOC_LAZY_FREE @@ -1646,6 +1646,7 @@ chunk_alloc_mmap(size_t size) return (NULL); /* Clean up unneeded leading/trailing space. */ + offset = CHUNK_ADDR2OFFSET(ret); if (offset != 0) { /* Leading space. */ pages_unmap(ret, chunksize - offset); @@ -1661,11 +1662,11 @@ chunk_alloc_mmap(size_t size) pages_unmap((void *)((uintptr_t)ret + size), chunksize); } + } else { + /* Clean up unneeded leading space. */ + pages_unmap(ret, chunksize - offset); + ret = (void *)((uintptr_t)ret + (chunksize - offset)); } - - /* Clean up unneeded leading space. */ - pages_unmap(ret, chunksize - offset); - ret = (void *)((uintptr_t)ret + (chunksize - offset)); } return (ret); |