#ifndef _UTIL_H
#define _UTIL_H
+#define exit_if_null(pointer, ...) { if (pointer == NULL) die(__VA_ARGS__); }
+
int min(int a, int b);
int max(int a, int b);
-void exit_if_null(void *pointer, char *fmt, ...);
void die(char *fmt, ...);
void *smalloc(size_t size);
char *sstrdup(const char *str);
info_cookie = xcb_list_fonts_with_info(connection, 1, strlen(pattern), pattern);
check_error(connection, font_cookie, "Could not open font");
- check_error(connection, info_cookie, "Could not get font information");
/* Get information (height/name) for this font */
- xcb_list_fonts_with_info_reply_t *reply = xcb_list_fonts_with_info_reply(connection, cookie, NULL);
+ xcb_list_fonts_with_info_reply_t *reply = xcb_list_fonts_with_info_reply(connection, info_cookie, NULL);
exit_if_null(reply, "Could not load font \"%s\"\n", pattern);
if (asprintf(&(new->name), "%.*s", xcb_list_fonts_with_info_name_length(reply),
#include "data.h"
#include "table.h"
#include "layout.h"
+#include "util.h"
int min(int a, int b) {
return (a < b ? a : 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.
*