6 #include "eruntime/smalloc.h"
12 #define __noreturn __attribute__((__noreturn__))
13 static void __noreturn
oom (oom_data_t
*);
15 /* {{{ void *smalloc() */
26 fprintf(stderr
, "WARNING: %s() called with size argument of '0', "
27 "falling back to '1'", __FUNCTION__
);
34 oom_data
.caller
= OOM_SMALLOC
;
35 oom_data
.a
.size
= size
;
40 /* {{{ void sfree() */
50 /* {{{ static void oom() */
52 oom (oom_data_t
*oom_data
)
54 char buf
[8] = {0}; /* strlen("realloc") + 1 */
58 if (oom_data
->caller
== OOM_SMALLOC
)
60 strcpy(buf
, "malloc");
65 fprintf(stderr
, "ERROR: %s() called with invalid ->caller '%d'",
66 __FUNCTION__
, oom_data
->caller
);
70 fprintf(stderr
, "ERROR: Out Of Memory Condition; %s() aborting",
74 fprintf(stderr
, "ERROR: %s\n", buf
);
76 fprintf(stderr
, "ERROR: %s (errno %d)", strerror(errno
), errno
);
86 * vim: ts=8 sw=8 noet fdm=marker tw=80