From 9bb42946a8791addade91b9e9379f94b144429f7 Mon Sep 17 00:00:00 2001 From: okan Date: Sat, 28 Mar 2015 23:12:47 +0000 Subject: Introduce a xreallocarray and convert a few xcalloc instances that do not require zero'ing. --- xmalloc.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'xmalloc.c') diff --git a/xmalloc.c b/xmalloc.c index 94f0691..21a65d7 100644 --- a/xmalloc.c +++ b/xmalloc.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: xmalloc.c,v 1.14 2015/01/19 14:54:16 okan Exp $ + * $OpenBSD: xmalloc.c,v 1.15 2015/03/28 23:12:47 okan Exp $ */ #include @@ -61,6 +61,18 @@ xcalloc(size_t no, size_t siz) return(p); } +void * +xreallocarray(void *ptr, size_t nmemb, size_t size) +{ + void *p; + + p = reallocarray(ptr, nmemb, size); + if (p == NULL) + errx(1, "xreallocarray: out of memory (new_size %zu bytes)", + nmemb * size); + return(p); +} + char * xstrdup(const char *str) { -- cgit v1.2.3-2-gb3c3