From: oetiker Date: Wed, 6 Feb 2008 00:10:33 +0000 (+0000) Subject: * replaced strtok with strtok_r for thread safety X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=84e75cc04c0fce4574301273b676370226d5f900;p=rrdtool-all.git * replaced strtok with strtok_r for thread safety * fixed im initialization broken after the introduction of dashes ... git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk@1279 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/program/src/rrd_graph.c b/program/src/rrd_graph.c index 8c118682..501db48d 100644 --- a/program/src/rrd_graph.c +++ b/program/src/rrd_graph.c @@ -3450,6 +3450,9 @@ int gdes_alloc( im->gdes[im->gdes_c - 1].rpnp = NULL; im->gdes[im->gdes_c - 1].p_dashes = NULL; im->gdes[im->gdes_c - 1].shift = 0.0; + im->gdes[im->gdes_c - 1].dash = 0; + im->gdes[im->gdes_c - 1].ndash = 0; + im->gdes[im->gdes_c - 1].offset = 0; im->gdes[im->gdes_c - 1].col.red = 0.0; im->gdes[im->gdes_c - 1].col.green = 0.0; im->gdes[im->gdes_c - 1].col.blue = 0.0; diff --git a/program/src/rrd_graph_helper.c b/program/src/rrd_graph_helper.c index cac3d7a6..44f2c173 100644 --- a/program/src/rrd_graph_helper.c +++ b/program/src/rrd_graph_helper.c @@ -791,13 +791,14 @@ int rrd_parse_PVHLAST( char csv[64]; char *pch; float dsh; - - strcpy(csv, tmpstr); int count = 0; + char *saveptr; - pch = strtok(tmpstr, ","); + strcpy(csv, tmpstr); + + pch = strtok_r(tmpstr, ",",&saveptr); while (pch != NULL) { - pch = strtok(NULL, ","); + pch = strtok_r(NULL, ",",&saveptr); count++; } dprintf("- %d dash value(s) found: ", count); @@ -805,7 +806,7 @@ int rrd_parse_PVHLAST( gdp->dash = 1; gdp->ndash = count; gdp->p_dashes = (double *) malloc(sizeof(double) * count); - pch = strtok(csv, ","); + pch = strtok_r(csv, ",",&saveptr); count = 0; while (pch != NULL) { if (sscanf(pch, "%f", &dsh)) { @@ -813,7 +814,7 @@ int rrd_parse_PVHLAST( dprintf("%.1f ", gdp->p_dashes[count]); count++; } - pch = strtok(NULL, ","); + pch = strtok_r(NULL, ",",&saveptr); } dprintf("\n"); } else