git: a312f3e74286 - main - sort: add wrapper around calloc

From: Baptiste Daroussin <bapt_at_FreeBSD.org>
Date: Wed, 12 Oct 2022 14:12:17 UTC
The branch main has been updated by bapt:

URL: https://cgit.FreeBSD.org/src/commit/?id=a312f3e74286c9bccd498198bfd236c49916d891

commit a312f3e74286c9bccd498198bfd236c49916d891
Author:     Baptiste Daroussin <bapt@FreeBSD.org>
AuthorDate: 2022-10-12 13:52:38 +0000
Commit:     Baptiste Daroussin <bapt@FreeBSD.org>
CommitDate: 2022-10-12 14:12:04 +0000

    sort: add wrapper around calloc
---
 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 dea37bb3a110..18794666da51 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 cb21d6d4a221..6a4edcd59161 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);