it makes no sense allocating an array and then asiging it to a fixed string ...
[rrdtool.git] / src / rrd_not_thread_safe.c
1 /*****************************************************************************
2  * RRDtool 1.2.15  Copyright by Tobi Oetiker, 1997-2006
3  * This file:     Copyright 2003 Peter Stamfest <peter@stamfest.at> 
4  *                             & Tobias Oetiker
5  * Distributed under the GPL
6  *****************************************************************************
7  * rrd_not_thread_safe.c   Contains routines used when thread safety is not
8  *                         an issue
9  *****************************************************************************
10  * $Id$
11  *************************************************************************** */
12 #include "rrd.h"
13 #include "rrd_tool.h"
14 #define MAXLEN 4096
15 #define ERRBUFLEN 256
16
17 static char rrd_error[MAXLEN+10];
18 static char rrd_liberror[ERRBUFLEN+10];
19 /* The global context is very useful in the transition period to even
20    more thread-safe stuff, it can be used whereever we need a context
21    and do not need to worry about concurrency. */
22 static struct rrd_context global_ctx = {
23     MAXLEN,
24     ERRBUFLEN,
25     rrd_error, 
26     rrd_liberror
27 };
28 /* #include <stdarg.h> */
29
30 struct rrd_context *rrd_get_context(void) {
31     return &global_ctx;
32 }
33
34 /* how ugly that is!!! - make sure strerror is what it should be. It
35    might be redefined to help in keeping other modules thread safe by
36    silently turning misplaced strerror into rrd_strerror, but here
37    this turns recursive! */
38 #undef strerror
39 const char *rrd_strerror(int err) {
40     return strerror(err);
41 }