diff --git a/examples/io.c b/examples/io.c index 2cab495b9a22a50fb88596de2564d38343cefea2..148615960bb3938d945e0f8910503bcea8391d21 100644 --- a/examples/io.c +++ b/examples/io.c @@ -37,6 +37,19 @@ int quiet_flag = 0; +void * +xalloc(size_t size) +{ + void *p = malloc(size); + if (!p) + { + fprintf(stderr, "Virtual memory exhausted.\n"); + abort(); + } + + return p; +} + void werror(const char *format, ...) { diff --git a/examples/io.h b/examples/io.h index acd864f2754d31b5beecad49a6673febac6c5482..a5211951dcb561e9923cb30415f574646e034ac3 100644 --- a/examples/io.h +++ b/examples/io.h @@ -34,6 +34,9 @@ extern int quiet_flag; +void * +xalloc(size_t size); + void werror(const char *format, ...) #if __GNUC___