From: oetiker Date: Sat, 16 Dec 2006 15:56:26 +0000 (+0000) Subject: it makes no sense allocating an array and then asiging it to a fixed string ... X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=eaa7cd6040fe27ced6746492a55174d6f0b034d5;p=rrdtool.git it makes no sense allocating an array and then asiging it to a fixed string ... this caused stuff to crash badly as long error strings were assigned. git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2/program@929 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/src/rrd_not_thread_safe.c b/src/rrd_not_thread_safe.c index 2d3b350..7022277 100644 --- a/src/rrd_not_thread_safe.c +++ b/src/rrd_not_thread_safe.c @@ -14,20 +14,20 @@ #define MAXLEN 4096 #define ERRBUFLEN 256 -static char rrd_error[MAXLEN] = "\0"; -static char rrd_liberror[ERRBUFLEN] = "\0"; +static char rrd_error[MAXLEN+10]; +static char rrd_liberror[ERRBUFLEN+10]; /* The global context is very useful in the transition period to even more thread-safe stuff, it can be used whereever we need a context and do not need to worry about concurrency. */ static struct rrd_context global_ctx = { - sizeof(rrd_error), - sizeof(rrd_liberror), + MAXLEN, + ERRBUFLEN, rrd_error, rrd_liberror }; -#include +/* #include */ -struct rrd_context *rrd_get_context() { +struct rrd_context *rrd_get_context(void) { return &global_ctx; }