diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-04-24 01:36:02 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-04-24 01:36:02 +0000 |
commit | aff8f00219609c0ea796bfd93aa7e6202a9bffb2 (patch) | |
tree | a69255bf7ec86dfecb50338c8bbddebc1be38781 /usr.bin/ssh/xmalloc.c | |
parent | ab54c1813b5d672bc5e0c82fdfa2c13bd3890a7d (diff) |
rename xrealloc() to xreallocarray() since it follows that form.
ok djm
Diffstat (limited to 'usr.bin/ssh/xmalloc.c')
-rw-r--r-- | usr.bin/ssh/xmalloc.c | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/usr.bin/ssh/xmalloc.c b/usr.bin/ssh/xmalloc.c index d2bbfe2d0d3..0f37c616951 100644 --- a/usr.bin/ssh/xmalloc.c +++ b/usr.bin/ssh/xmalloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xmalloc.c,v 1.31 2015/02/06 23:21:59 millert Exp $ */ +/* $OpenBSD: xmalloc.c,v 1.32 2015/04/24 01:36:01 deraadt Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -52,22 +52,14 @@ 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; - if (new_size == 0) - 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 = reallocarray(ptr, nmemb, size); if (new_ptr == NULL) - fatal("xrealloc: out of memory (new_size %zu bytes)", - new_size); + fatal("xreallocarray: out of memory (%zu elements of %zu bytes)", + nmemb, size); return new_ptr; } |