From: <and...@us...> - 2011-11-30 22:04:49
|
Revision: 12077 http://plplot.svn.sourceforge.net/plplot/?rev=12077&view=rev Author: andrewross Date: 2011-11-30 22:04:42 +0000 (Wed, 30 Nov 2011) Log Message: ----------- The Tcl interp->result string should not be set directly, but via Tcl_SetResult. Direct access is deprecated and is a potential source of memory leaks / string errors. This still needs fixing up in the tk bindings as well. Modified Paths: -------------- trunk/examples/tk/xtk02.c trunk/examples/tk/xtk04.c Modified: trunk/examples/tk/xtk02.c =================================================================== --- trunk/examples/tk/xtk02.c 2011-11-30 14:22:37 UTC (rev 12076) +++ trunk/examples/tk/xtk02.c 2011-11-30 22:04:42 UTC (rev 12077) @@ -52,7 +52,7 @@ pm->fdata[i] = y; } - interp->result = "Things are cool in gumbyville."; + Tcl_SetResult( interp, (char *) "Things are cool in gumbyville.", TCL_STATIC ); return TCL_OK; } Modified: trunk/examples/tk/xtk04.c =================================================================== --- trunk/examples/tk/xtk04.c 2011-11-30 14:22:37 UTC (rev 12076) +++ trunk/examples/tk/xtk04.c 2011-11-30 22:04:42 UTC (rev 12077) @@ -33,12 +33,14 @@ int PL_UNUSED( argc ), const char *PL_UNUSED( argv[] ) ) { PLFLT max = pm->fdata[0]; + char res[30]; int i; for ( i = 1; i < pm->len; i++ ) if ( pm->fdata[i] > max ) max = pm->fdata[i]; - sprintf( interp->result, "%f", max ); + sprintf( res, "%f", max ); + Tcl_SetResult( interp, res, TCL_VOLATILE ); return TCL_OK; } @@ -46,12 +48,14 @@ int PL_UNUSED( argc ), const char *PL_UNUSED( argv[] ) ) { PLFLT min = pm->fdata[0]; + char res[30]; int i; for ( i = 1; i < pm->len; i++ ) if ( pm->fdata[i] < min ) min = pm->fdata[i]; - sprintf( interp->result, "%f", min ); + sprintf( res, "%f", min ); + Tcl_SetResult( interp, res, TCL_VOLATILE ); return TCL_OK; } @@ -162,7 +166,7 @@ if ( pm->dim != 2 ) { - interp->result = "must use 2-d matrix."; + Tcl_SetResult( interp, (char *) "must use 2-d matrix.", TCL_STATIC ); return TCL_ERROR; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |