--- /dev/null
+#include "_memory.h"
+#pragma GCC poison malloc
+#pragma GCC poison calloc
+#pragma GCC poison realloc
#include <stdarg.h>
#include <stdio.h>
+#include <stdlib.h>
#include "printf.h"
+#include "memory.h"
int main()
{
+ void *x;
+
efprintf(stdout, "Hello, world!\n");
+ x = emalloc(sizeof(int));
+ free(x);
return 0;
}
--- /dev/null
+#include <stdlib.h>
+#include "_memory.h"
+
+#include "abort.h"
+
+void *emalloc(size_t n)
+{
+ void *p = malloc(n);
+ if (p == NULL)
+ abort_with_error("Memory allocation failure\n");
+
+ return p;
+}
+
+void *ecalloc(size_t n, size_t m)
+{
+ void *p = calloc(n, m);
+ if (p == NULL)
+ abort_with_error("Memory allocation failure\n");
+
+ return p;
+}
+
+void *erealloc(void *q, size_t n)
+{
+ void *p = realloc(q, n);
+ if (p == NULL)
+ abort_with_error("Memory allocation failure\n");
+
+ return p;
+}