@m455 IMHO, the only sane #error #handling for #malloc is something like this:
void *xmalloc(size_t sz)
{
void *p = malloc(sz);
if (!p) abort();
return p;
}
Rationale: On a "modern" OS, malloc never fails unless you'd exhaust address space (NOT available RAM). If it does, something in the OS broke. The reasons for this (see also "memory overcommitment") are a bit ugly, but that's where we are.
Even if you were on some special system (e.g. embedded) where malloc *does* fail on out-of-memory, you'd rarely find a sane strategy to continue doing anything meaningful in your program if it doesn't get the memory it needs, so, most of the time, just #abort is the sane choice here as well.