new function: die(...)

This commit is contained in:
Sascha Kruse 2012-07-25 06:34:31 +02:00
parent 1b4b7c3ae2
commit 03411ac365

12
dunst.c
View File

@ -137,6 +137,12 @@ void print_version(void);
void init_shortcut(keyboard_shortcut * shortcut); void init_shortcut(keyboard_shortcut * shortcut);
KeySym string_to_mask(char *str); KeySym string_to_mask(char *str);
void die(char *text, int exit_value)
{
fputs(text, stderr);
exit(exit_value);
}
int cmp_notification(void *a, void *b) int cmp_notification(void *a, void *b)
{ {
if (a == NULL && b == NULL) if (a == NULL && b == NULL)
@ -842,10 +848,8 @@ void init_shortcut(keyboard_shortcut * ks)
char *str = strdup(ks->str); char *str = strdup(ks->str);
char *str_begin = str; char *str_begin = str;
if (str == NULL) { if (str == NULL)
fprintf(stderr, "Unable to allocate memory"); die("Unable to allocate memory", EXIT_FAILURE);
exit(EXIT_FAILURE);
}
while (strstr(str, "+")) { while (strstr(str, "+")) {
char *mod = str; char *mod = str;