aboutsummaryrefslogtreecommitdiffstats
path: root/calloc.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2019-11-01 22:06:40 +0100
committerMattias Andrée <maandree@kth.se>2019-11-01 22:06:40 +0100
commitc57844b08bced71778f38f2346464c3e0836287c (patch)
treee3733b4c99818ee6c77ed3d4d37becf30f92268f /calloc.c
parentUse installed liberror (diff)
downloadliberror-libc-c57844b08bced71778f38f2346464c3e0836287c.tar.gz
liberror-libc-c57844b08bced71778f38f2346464c3e0836287c.tar.bz2
liberror-libc-c57844b08bced71778f38f2346464c3e0836287c.tar.xz
Add some functions and add functions with _failed suffix
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'calloc.c')
-rw-r--r--calloc.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/calloc.c b/calloc.c
new file mode 100644
index 0000000..86a939c
--- /dev/null
+++ b/calloc.c
@@ -0,0 +1,24 @@
+/* See LICENSE file for copyright and license details. */
+#include "internal.h"
+
+
+void
+liberror_calloc_failed(size_t n, size_t m)
+{
+ liberror_set_error_errno("Out of memory", "calloc", ENOMEM);
+ errno = ENOMEM;
+ (void) n;
+ (void) m;
+}
+
+
+void *
+liberror_calloc(size_t n, size_t m)
+{
+ void *ret = calloc(n, m);
+ if (ret || !n || !m)
+ return ret;
+ liberror_save_backtrace(NULL);
+ liberror_calloc_failed(n, m);
+ return NULL;
+}