git: accbb97f87e7 - stable/13 - sort: add wrapper around calloc

From: Baptiste Daroussin <bapt_at_FreeBSD.org>
Date: Wed, 19 Oct 2022 08:01:24 UTC
The branch stable/13 has been updated by bapt:

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

commit accbb97f87e7122c0887faece1efc852719c4bdb
Author:     Baptiste Daroussin <bapt@FreeBSD.org>
AuthorDate: 2022-10-12 13:52:38 +0000
Commit:     Baptiste Daroussin <bapt@FreeBSD.org>
CommitDate: 2022-10-19 07:56:51 +0000

    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 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);