From accbb97f87e7122c0887faece1efc852719c4bdb Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Wed, 12 Oct 2022 15:52:38 +0200 Subject: [PATCH] sort: add wrapper around calloc (cherry picked from commit a312f3e74286c9bccd498198bfd236c49916d891) --- usr.bin/sort/mem.c | 10 ++++++++++ usr.bin/sort/mem.h | 1 + 2 files changed, 11 insertions(+) diff --git a/usr.bin/sort/mem.c b/usr.bin/sort/mem.c index dea37bb3a11..18794666da5 100644 --- a/usr.bin/sort/mem.c +++ b/usr.bin/sort/mem.c @@ -36,6 +36,16 @@ __FBSDID("$FreeBSD$"); #include "mem.h" +void* +sort_calloc(size_t nb, size_t size) +{ + void *ptr; + + if ((ptr = calloc(nb, size)) == NULL) + err(2, NULL); + return (ptr); +} + /* * malloc() wrapper. */ diff --git a/usr.bin/sort/mem.h b/usr.bin/sort/mem.h index cb21d6d4a22..6a4edcd5916 100644 --- a/usr.bin/sort/mem.h +++ b/usr.bin/sort/mem.h @@ -39,6 +39,7 @@ /* * mem.c */ +void *sort_calloc(size_t, size_t); void *sort_malloc(size_t); void sort_free(const void *ptr); void *sort_realloc(void *, size_t);