diff --git a/hogs/memhog.c b/hogs/memhog.c index 03cf6b6..90a29a7 100644 --- a/hogs/memhog.c +++ b/hogs/memhog.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -8,6 +9,7 @@ int main(void) { while (s) { void *p; + errno = 0; if (p = malloc(s)) { sum += s; printf("%lu - %lu\n", @@ -17,6 +19,11 @@ int main(void) { memset(p, 'a', s); s *= 2; } else { + printf("%lu - %lu: %s\n", + (unsigned long)s, + (unsigned long)sum, + strerror(errno) + ); s /= 2; } }