From: Tobias Oetiker Date: Sat, 16 Dec 2006 16:10:58 +0000 (+0000) Subject: init the context on first call X-Git-Tag: 1.2.16~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a40b7005f8b7d05bf233d487f4e55ee96cd44c5b;p=thirdparty%2Frrdtool-1.x.git init the context on first call git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2/program@935 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/src/rrd_not_thread_safe.c b/src/rrd_not_thread_safe.c index 70222770..7b6a2565 100644 --- a/src/rrd_not_thread_safe.c +++ b/src/rrd_not_thread_safe.c @@ -16,6 +16,7 @@ static char rrd_error[MAXLEN+10]; static char rrd_liberror[ERRBUFLEN+10]; +static int rrd_context_init = 0; /* 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. */ @@ -28,6 +29,11 @@ static struct rrd_context global_ctx = { /* #include */ struct rrd_context *rrd_get_context(void) { + if (! rrd_context_init ){ + rrd_context_init = 1; + global_ctx.rrd_error[0]='\0'; + global_ctx.lib_errstr[0]='\0'; + } return &global_ctx; }