summaryrefslogtreecommitdiff
path: root/usr.bin/cvs/xmalloc.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2014-12-01 21:58:47 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2014-12-01 21:58:47 +0000
commit63b1dc9d5d7158229afedc4c7c7db0d30a99c6b6 (patch)
treec3a9c79effa70af6f0f134fa99314869fe429e59 /usr.bin/cvs/xmalloc.c
parente0af19e7664629a09fce64e756b718edfed96da1 (diff)
An internal function called xrealloc() is actually a fail-hard
reallocarray()... so rename it.
Diffstat (limited to 'usr.bin/cvs/xmalloc.c')
-rw-r--r--usr.bin/cvs/xmalloc.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/usr.bin/cvs/xmalloc.c b/usr.bin/cvs/xmalloc.c
index 009ccc063a9..806cd3e1476 100644
--- a/usr.bin/cvs/xmalloc.c
+++ b/usr.bin/cvs/xmalloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xmalloc.c,v 1.9 2009/06/07 08:39:13 ray Exp $ */
+/* $OpenBSD: xmalloc.c,v 1.10 2014/12/01 21:58:46 deraadt Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -51,7 +51,7 @@ xcalloc(size_t nmemb, size_t size)
}
void *
-xrealloc(void *ptr, size_t nmemb, size_t size)
+xreallocarray(void *ptr, size_t nmemb, size_t size)
{
void *new_ptr;
size_t new_size = nmemb * size;
@@ -60,10 +60,7 @@ xrealloc(void *ptr, size_t nmemb, size_t size)
fatal("xrealloc: zero size");
if (SIZE_MAX / nmemb < size)
fatal("xrealloc: nmemb * size > SIZE_MAX");
- if (ptr == NULL)
- new_ptr = malloc(new_size);
- else
- new_ptr = realloc(ptr, new_size);
+ new_ptr = realloc(ptr, new_size);
if (new_ptr == NULL)
fatal("xrealloc: out of memory (new_size %lu bytes)",
(u_long) new_size);