commit 3fec3e2f4cd0d4b5dfe2f851dc135787f0e377fe
Author: Michael Forney <[email protected]>
AuthorDate: Tue Apr 16 17:41:39 2019 -0700
Commit: Michael Forney <[email protected]>
CommitDate: Tue Apr 16 17:41:39 2019 -0700
libutil: Add enreallocarray
diff --git a/libutil/reallocarray.c b/libutil/reallocarray.c
index c6e5219..31ff6c3 100644
--- a/libutil/reallocarray.c
+++ b/libutil/reallocarray.c
@@ -40,11 +40,17 @@ reallocarray(void *optr, size_t nmemb, size_t size)
void *
ereallocarray(void *optr, size_t nmemb, size_t size)
+{
+ return enreallocarray(1, optr, nmemb, size);
+}
+
+void *
+enreallocarray(int status, void *optr, size_t nmemb, size_t size)
{
void *p;
if (!(p = reallocarray(optr, nmemb, size)))
- eprintf("reallocarray: out of memory\n");
+ enprintf(status, "reallocarray: out of memory\n");
return p;
}
diff --git a/util.h b/util.h
index 1f3cd0c..6c0aba9 100644
--- a/util.h
+++ b/util.h
@@ -32,6 +32,7 @@ char *estrndup(const char *, size_t);
void *encalloc(int, size_t, size_t);
void *enmalloc(int, size_t);
void *enrealloc(int, void *, size_t);
+void *enreallocarray(int, void *, size_t, size_t);
char *enstrdup(int, const char *);
char *enstrndup(int, const char *, size_t);