]> mj.ucw.cz Git - eval.git/blob - judge/utils.c
Implemented output filters (see OUTPUT_FILTER config variable).
[eval.git] / judge / utils.c
1 /*
2  *      Utility functions for judges
3  *
4  *      (c) 2007 Martin Mares <mj@ucw.cz>
5  */
6
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <stdarg.h>
10
11 #include "judge.h"
12
13 void die(char *msg, ...)
14 {
15   va_list args;
16   va_start(args, msg);
17   vfprintf(stderr, msg, args);
18   fputc('\n', stderr);
19   va_end(args);
20   exit(1);
21 }
22
23 void *xmalloc(size_t size)
24 {
25   void *p = malloc(size);
26   if (!p)
27     die("Out of memory (unable to allocate %z bytes)", size);
28   return p;
29 }
30
31 void *xrealloc(void *p, size_t size)
32 {
33   p = realloc(p, size);
34   if (!p)
35     die("Out of memory (unable to allocate %z bytes)", size);
36   return p;
37 }