Skip to content

Instantly share code, notes, and snippets.

@anaisbetts
Created October 15, 2011 10:51
Show Gist options
  • Select an option

  • Save anaisbetts/1289394 to your computer and use it in GitHub Desktop.

Select an option

Save anaisbetts/1289394 to your computer and use it in GitHub Desktop.
// Provides convenient way to check whether memory allocation have succeeded.
#define alloc_assert(x) \
do {\
if (unlikely (!x)) {\
fprintf (stderr, "FATAL ERROR: OUT OF MEMORY (%s:%d)\n",\
__FILE__, __LINE__);\
_abort ("OUT OF MEMORY");\
}\
} while (false)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment