Implement exit_if_null using variadic macros, fix compilation

This commit is contained in:
Michael Stapelberg
2009-02-15 22:52:33 +01:00
parent 57f631b7a7
commit 7216738778
3 changed files with 4 additions and 21 deletions

View File

@ -21,6 +21,7 @@
#include "data.h"
#include "table.h"
#include "layout.h"
#include "util.h"
int min(int a, int b) {
return (a < b ? a : b);
@ -30,24 +31,6 @@ int max(int a, int b) {
return (a > b ? a : b);
}
/*
* Checks if pointer is NULL and exits the whole program, printing a message to stdout
* before with the given format (see printf())
*
*/
void exit_if_null(void *pointer, char *fmt, ...) {
va_list args;
if (pointer != NULL)
return;
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
exit(EXIT_FAILURE);
}
/*
* Prints the message (see printf()) to stderr, then exits the program.
*