diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2017-03-28 16:56:39 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2017-03-28 16:56:39 +0000 |
commit | e63db400608d323135ad0f538b15d6d281376285 (patch) | |
tree | 148d4e69874a288e31f1a5e6107d2c87653ceb82 /lib/libc/stdlib | |
parent | de4a918da4e1a9f018927d971d57dbac358ba604 (diff) |
small cleanup & optimization; ok deraadt@ millert@
Diffstat (limited to 'lib/libc/stdlib')
-rw-r--r-- | lib/libc/stdlib/malloc.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c index 688354f1e01..1e13c2de111 100644 --- a/lib/libc/stdlib/malloc.c +++ b/lib/libc/stdlib/malloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: malloc.c,v 1.217 2017/03/24 16:23:05 otto Exp $ */ +/* $OpenBSD: malloc.c,v 1.218 2017/03/28 16:56:38 otto Exp $ */ /* * Copyright (c) 2008, 2010, 2011, 2016 Otto Moerbeek <otto@drijf.net> * Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org> @@ -1703,6 +1703,9 @@ orecallocarray(struct dir_info *argpool, void *p, size_t oldsize, if (p == NULL) return omalloc(pool, newsize, 1, f); + if (oldsize == newsize) + return p; + r = find(pool, p); if (r == NULL) { if (mopts.malloc_mt) { @@ -1791,7 +1794,7 @@ recallocarray_p(void *ptr, size_t oldnmemb, size_t newnmemb, size_t size) if (newsize <= oldsize) { size_t d = oldsize - newsize; - if (d < oldsize / 2 && d < getpagesize()) { + if (d < oldsize / 2 && d < MALLOC_PAGESIZE) { memset((char *)ptr + newsize, 0, d); return ptr; } |