From 43e8868875e1d5287979e5b9060a9b16be45cc79 Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Tue, 22 Feb 2011 16:23:36 +0100 Subject: Added explicit error message in case of memory exhaustion Signed-off-by: Martin Sustrik --- src/err.hpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/err.hpp') diff --git a/src/err.hpp b/src/err.hpp index 9d8e153..fc8b7c1 100644 --- a/src/err.hpp +++ b/src/err.hpp @@ -98,7 +98,7 @@ namespace zmq }\ } while (false) -// Provides convenient way to check for POSIX errors. +// Provides convenient way to check for POSIX errors. #define posix_assert(x) \ do {\ if (unlikely (x)) {\ @@ -107,7 +107,7 @@ namespace zmq }\ } while (false) -// Provides convenient way to check for errors from getaddrinfo. +// Provides convenient way to check for errors from getaddrinfo. #define gai_assert(x) \ do {\ if (unlikely (x)) {\ @@ -117,10 +117,16 @@ namespace zmq }\ } while (false) -#endif - -#define zmq_not_implemented() \ +// Provides convenient way to check whether memory allocation have succeeded. +#define alloc_assert(x) \ do {\ - fprintf (stderr, "Hic sunt leones (%s:%d)\n", __FILE__, __LINE__);\ - abort ();\ + if (unlikely (!x)) {\ + fprintf (stderr, "FATAL ERROR: OUT OF MEMORY (%s:%d)\n",\ + __FILE__, __LINE__);\ + abort ();\ + }\ } while (false) + +#endif + + -- cgit v1.2.3