Best practice: Abort program

Hello everyone,

as seen in this thread, we are supposed to check if the dynamic memory allocation was successful or not. My question is:
Which of the following commands are best-practice to abort the program in find_and_carve_path in case dynamic memory allocation fails?

// nr. 1
exit(0);

// nr. 2
return EXIT_FAILURE;

// nr. 3
abort();

Or are we supposed to use any custom exception, like UNUSED() + NOT_IMPLEMENTED()? I couldn’t find any defined behaviour like these for this case, but I’m still not quiet sure :slight_smile:

Thanks in advance,
David

Calling abort() is what I would suggest. Writing a custom function that prints an error and then aborts is even better, since it allows the user to actually see what went wrong.