[PATCH 1/3] add en*alloc functions

From: Jakob Kramer <jakob.kramer_AT_gmx.de>
Date: Wed, 11 Feb 2015 01:40:52 +0100

---
 libutil/ealloc.c | 38 +++++++++++++++++++++++++++++++-------
 util.h           |  6 +++++-
 2 files changed, 36 insertions(+), 8 deletions(-)
diff --git a/libutil/ealloc.c b/libutil/ealloc.c
index 05bdd62..8e2f21e 100644
--- a/libutil/ealloc.c
+++ b/libutil/ealloc.c
_AT_@ -7,41 +7,65 @@
 void *
 ecalloc(size_t nmemb, size_t size)
 {
+	return encalloc(1, nmemb, size);
+}
+
+void *
+emalloc(size_t size)
+{
+	return enmalloc(1, size);
+}
+
+void *
+erealloc(void *p, size_t size)
+{
+	return enrealloc(1, p, size);
+}
+
+char *
+estrdup(const char *s)
+{
+	return enstrdup(1, s);
+}
+
+void *
+encalloc(int status, size_t nmemb, size_t size)
+{
 	void *p;
 
 	p = calloc(nmemb, size);
 	if (!p)
-		eprintf("calloc: out of memory\n");
+		enprintf(status, "calloc: out of memory\n");
 	return p;
 }
 
 void *
-emalloc(size_t size)
+enmalloc(int status, size_t size)
 {
 	void *p;
 
 	p = malloc(size);
 	if (!p)
-		eprintf("malloc: out of memory\n");
+		enprintf(status, "malloc: out of memory\n");
 	return p;
 }
 
 void *
-erealloc(void *p, size_t size)
+enrealloc(int status, void *p, size_t size)
 {
 	p = realloc(p, size);
 	if (!p)
-		eprintf("realloc: out of memory\n");
+		enprintf(status, "realloc: out of memory\n");
 	return p;
 }
 
 char *
-estrdup(const char *s)
+enstrdup(int status, const char *s)
 {
 	char *p;
 
 	p = strdup(s);
 	if (!p)
-		eprintf("strdup: out of memory\n");
+		enprintf(status, "strdup: out of memory\n");
 	return p;
 }
diff --git a/util.h b/util.h
index f9175b2..2efcd89 100644
--- a/util.h
+++ b/util.h
_AT_@ -22,9 +22,13 @@ char *agetcwd(void);
 void apathmax(char **, long *);
 
 void *ecalloc(size_t, size_t);
-void *emalloc(size_t size);
+void *emalloc(size_t);
 void *erealloc(void *, size_t);
 char *estrdup(const char *);
+void *encalloc(int, size_t, size_t);
+void *enmalloc(int, size_t);
+void *enrealloc(int, void *, size_t);
+char *enstrdup(int, const char *);
 
 void enprintf(int, const char *, ...);
 void eprintf(const char *, ...);
-- 
1.9.1
--------------070007090404080305050507--
Received on Mon Sep 17 2001 - 00:00:00 CEST

This archive was generated by hypermail 2.3.0 : Wed Feb 11 2015 - 02:12:07 CET