summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdlib/malloc.c
diff options
context:
space:
mode:
authorotto <otto@openbsd.org>2017-03-28 16:56:38 +0000
committerotto <otto@openbsd.org>2017-03-28 16:56:38 +0000
commit77328f45ecd42115d67436c83c4daeeca20e3f55 (patch)
tree7c2f06284688c6859faae7974bdae45b9114b0d2 /lib/libc/stdlib/malloc.c
parentDon't send informational responses before we're having the key material. (diff)
downloadwireguard-openbsd-77328f45ecd42115d67436c83c4daeeca20e3f55.tar.xz
wireguard-openbsd-77328f45ecd42115d67436c83c4daeeca20e3f55.zip
small cleanup & optimization; ok deraadt@ millert@
Diffstat (limited to 'lib/libc/stdlib/malloc.c')
-rw-r--r--lib/libc/stdlib/malloc.c7
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;
}