blob: a2f1f7bc83d42627ec291a49d6ed5364ecb10018 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
/*
* util.h:
* Utilities.
*
* Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved.
* Email: chris@mysociety.org; WWW: http://www.mysociety.org/
*
* $Id: util.h,v 1.1 2006-09-20 15:45:51 chris Exp $
*
*/
#ifndef __UTIL_H_ /* include guard */
#define __UTIL_H_
/* err FORMAT [ARG ...]
* Write an error message to standard error. */
/* XXX format this with a timestamp for the error-log? */
#define err(...) \
do { \
fprintf(stderr, "tileserver: "); \
fprintf(stderr, __VA_ARGS__); \
fprintf(stderr, "\n"); \
} while (0)
/* die FORMAT [ARG ...]
* Write an error message to standard error and exit unsuccessfully. */
#define die(...) do { err(__VA_ARGS__); exit(1); } while (0)
/* util.c */
void *xmalloc(const size_t s);
void *xcalloc(const size_t a, const size_t b);
void *xrealloc(void *b, const size_t s);
char *xstrdup(const char *s);
void xfree(void *v);
#endif /* __UTIL_H_ */
|