1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700
|
Description: upstream -- valgring: silence
Attempt to silence error messages as emitted by valgrind(1),
mainly memory leaks and use of uninitialised objects.
Origin: debian
Forwarded: meant to be submitted to the upstream maintainer team
Author: Jerome Benoit <calculus@rezozer.net>
Last-Update: 2015-05-26
--- a/yaccsrc/lexfunc.cc
+++ b/yaccsrc/lexfunc.cc
@@ -232,7 +232,7 @@
/* Delete system symbols in symtab */
/* ------------------------------------------------------------------------- */
-void symtab_delete_surface_names( void )
+void symtab_delete_surface_names( void )
{
symtab *s = s_first;
symtab *s_next = (symtab*)NULL;
@@ -240,6 +240,22 @@
while( s != (symtab*)NULL ) {
if( s->surface ) {
s_next = s->next;
+ if (s->name != NULL) {
+ free( s->name );
+ s->name = NULL;
+ }
+ switch (s->type) {
+ case SYM_STRING:
+ if (s->ptr != NULL) {
+ char *str_ptr = *(char**)(s->ptr);
+ if (str_ptr != NULL) {
+ delete_char( str_ptr ); str_ptr = NULL;
+ }
+ s->ptr = NULL;
+ }
+ break;
+ default: break;
+ }
symtab_delete_element( s );
s = s_next;
} else {
@@ -346,9 +362,13 @@
void symtab_delete_total( void )
{
symtab *s = s_first;
-
+
while( s != (symtab*)NULL ) {
symtab *s_next = s->next;
+ if (s->name != NULL) {
+ free( s->name );
+ s->name = NULL;
+ }
symtab_delete_element( s );
s = s_next;
}
--- a/yaccsrc/Script.cc
+++ b/yaccsrc/Script.cc
@@ -207,16 +207,16 @@
main_formula_pxyz_data[i].n = 0;
}
- ostrstream str;
- str << getDefaultValues() << ends;
+ ostrstream astr;
+ astr << getDefaultValues() << ends;
- internalExecuteScript (str.str());
+ internalExecuteScript (astr.str());
// symtab_set_default();
error_begin_char = 0;
char_number=0;
symtab_delete_user_names( );
-
*zbuffer = -10.0;
+ astr.freeze(false);
}
int Script::internalExecuteScript (const char *str, bool runCommands)
@@ -254,6 +254,35 @@
return parse_result;
}
+void Script::afterScriptExecution()
+{
+ int i;
+ for( i=0; i<int(sizeof(sym_cutsurfaces)/sizeof(sym_cutsurfaces[0])); i++) {
+ if (sym_cutsurfaces[i].n) {
+ delete_coeff_polyxyz( &sym_cutsurfaces[i] );
+ sym_cutsurfaces[i].m = NULL;
+ sym_cutsurfaces[i].deg = DEG_UNSPEC;
+ sym_cutsurfaces[i].n = 0;
+ }
+ }
+ for( i=0; i<MAIN_CLIP_AMOUNT_NUM; i++ ) {
+ if (main_formula_pxyz_data[i].n) {
+ delete_coeff_polyxyz( &main_clip_pxyz_data[i] );
+ main_clip_pxyz_data[i].m = NULL;
+ main_clip_pxyz_data[i].deg = DEG_UNSPEC;
+ main_clip_pxyz_data[i].n = 0;
+ }
+ }
+ for( i=0; i<MAIN_SURFACE_AMOUNT_NUM; i++ ) {
+ if (main_formula_pxyz_data[i].n) {
+ delete_coeff_polyxyz( &main_formula_pxyz_data[i] );
+ main_formula_pxyz_data[i].m = NULL;
+ main_formula_pxyz_data[i].deg = DEG_UNSPEC;
+ main_formula_pxyz_data[i].n = 0;
+ }
+ }
+ draw_func_reinit_parser();
+}
char *Script::readFile (const char *name)
{
@@ -265,6 +294,7 @@
ostrstream ostr;
ostr << "Cant stat file " << name << "" << " (" << strerror(errno) << ")" << ends;
Misc::alert (ostr);
+ ostr.freeze(false);
return 0;
}
@@ -274,26 +304,29 @@
ostrstream ostr;
ostr << "Cant open file " << name << "" << " (" << strerror(errno) << ")";
Misc::alert (ostr);
+ ostr.freeze(false);
return 0;
}
-
+
char *str = new char [size+1];
if (fread(str, 1, size, f) != size) {
ostrstream ostr;
ostr << "Could not read from file " << name << "" << " (" << strerror(errno) << ")";
Misc::alert(ostr);
- delete str;
+ delete []str;
fclose(f);
+ ostr.freeze(false);
return 0;
}
fclose(f);
str[size]=0;
if (strlen(str) < size) {
- delete str;
+ delete []str;
ostrstream ostr;
ostr << "\"" << name << "\" contains binary data.";
Misc::alert(ostr);
+ ostr.freeze(false);
return 0;
}
return str;
@@ -307,7 +340,8 @@
display=0;
beforeScriptExecution();
internalExecuteScript(str);
- delete str;
+ afterScriptExecution();
+ delete []str;
}
void Script::init()
@@ -332,7 +366,9 @@
delete bitbuffer;
delete zbuffer;
delete defaultValues;
+ symtab_delete_surface_names();
symtab_delete_total();
+ yy_deinit_global();
}
void Script::addNewCommands()
--- a/src/main.cc
+++ b/src/main.cc
@@ -72,7 +72,8 @@
start_gtk_main();
#endif
}
-
+
deinit_all();
+ delete options;
return 0;
}
--- a/yaccsrc/polylexyacc.h
+++ b/yaccsrc/polylexyacc.h
@@ -121,7 +121,7 @@
void yyrestart( FILE* );
int yyparse( void );
void set_the_yyinput( char*,long int,long int );
-
+int yy_deinit_global( void );
symtab *symtab_add_name ( const char* );
--- a/yaccsrc/polylex.l
+++ b/yaccsrc/polylex.l
@@ -344,6 +344,10 @@
%%
+int yy_deinit_global (void) {
+ yylex_destroy();
+ return 0;
+}
/* ------------------------------------------------------------------------- */
/* end of file: polylex.l */
--- a/draw/SurfaceCalc.cc
+++ b/draw/SurfaceCalc.cc
@@ -44,6 +44,14 @@
#include "float_buffer.h"
#include "antialiasing_factor.h"
+#ifndef NAN
+#define NAN 0.0/0.0
+#endif
+
+#ifndef INFINITY
+#define INFINTTY 1.0/0.0
+#endif
+
// FIXME
extern double Y_AXIS_LR_ROTATE;
@@ -108,9 +116,9 @@
pixel_color_refine.setBlack();
- double root[MAIN_SURFACE_AMOUNT_NUM][MAX_DEGREE];
- double root_last_pixel[MAIN_SURFACE_AMOUNT_NUM][MAX_DEGREE];
- int root_last_pixel_n[MAIN_SURFACE_AMOUNT_NUM];
+ double root[MAIN_SURFACE_AMOUNT_NUM][MAX_DEGREE] = { { NAN } };
+ double root_last_pixel[MAIN_SURFACE_AMOUNT_NUM][MAX_DEGREE] = { { INFINITY } };
+ int root_last_pixel_n[MAIN_SURFACE_AMOUNT_NUM] = { -1 };
double refine_radius=display_ref_radius_data;
@@ -262,6 +270,7 @@
SurfaceCalc::~SurfaceCalc()
{
+ delete clipper;
}
inline int SurfaceCalc::needsRefining (const colorrgb &i1, const colorrgb &i2, const colorrgb &i3,
@@ -341,9 +350,9 @@
// ----------------
// root variables
// ----------------
- double root[MAIN_SURFACE_AMOUNT_NUM][MAX_DEGREE];
- double root_last_pixel[MAIN_SURFACE_AMOUNT_NUM][MAX_DEGREE];
- int root_last_pixel_n[MAIN_SURFACE_AMOUNT_NUM];
+ double root[MAIN_SURFACE_AMOUNT_NUM][MAX_DEGREE] = { { NAN } };
+ double root_last_pixel[MAIN_SURFACE_AMOUNT_NUM][MAX_DEGREE] = { { INFINITY } };
+ int root_last_pixel_n[MAIN_SURFACE_AMOUNT_NUM] = { -1 };
initVars();
@@ -1043,9 +1052,9 @@
// --------------------------------------------------------------
// Root - Variablen
- double root[MAIN_SURFACE_AMOUNT_NUM+1][MAX_DEGREE];
- double root_last_pixel[MAIN_SURFACE_AMOUNT_NUM+1][MAX_DEGREE];
- int root_last_pixel_n[MAIN_SURFACE_AMOUNT_NUM+1];
+ double root[MAIN_SURFACE_AMOUNT_NUM+1][MAX_DEGREE] = { { NAN } };
+ double root_last_pixel[MAIN_SURFACE_AMOUNT_NUM+1][MAX_DEGREE] = { { INFINITY } };
+ int root_last_pixel_n[MAIN_SURFACE_AMOUNT_NUM+1] = { -1 };
double tmp;
float distf = (float)(display_numeric.stereo_z*display_numeric.stereo_eye/position_numeric.spectator_z);
--- a/yaccsrc/simple.c
+++ b/yaccsrc/simple.c
@@ -82,6 +82,18 @@
(int**)NULL
};
+static void binom_struct_destroy( void )
+{
+ int i;
+ for( i = 0; i <= b_c.created; ++i) {
+ free( b_c.data[i] );
+ b_c.data[i] = NULL;
+ }
+ free( b_c.data );
+ b_c.data = NULL;
+ b_c.created = -1;
+}
+
static void binom_struct_create_row( int n )
{
if( n == 0 ) {
@@ -106,10 +118,12 @@
{
int i;
+ if(b_c.created < 0) atexit( binom_struct_destroy );
+
b_c.data = renew_int_p( b_c.data,n + 1 );
for( i = b_c.created +1; i <= n; i++ ) {
- b_c.data[i] = new int[i + 1];
+ b_c.data[i] = (int *)(malloc((size_t)(i+1)*sizeof(int) ));
binom_struct_create_row( i );
}
@@ -204,7 +218,7 @@
{
if( n > 0 ) {
int **i;
- i = (int**)malloc( n*sizeof(int*) );
+ i = (int**)malloc((size_t)(n)*sizeof(int*) );
if( i == (int**)NULL ) {
(void)fprintf( stderr,"can't allocate %d pointers to int\n",n );
@@ -224,7 +238,7 @@
if( i == (int**)NULL ) {
return new_int_p( n );
} else if( n > 0 ) {
- i = (int**)realloc( (void**)i,n*sizeof(int*) );
+ i = (int**)realloc( (void**)i,(size_t)(n)*sizeof(int*) );
if( i == (int**)NULL ) {
(void)fprintf( stderr,"can't realloc %d pointers to int\n",n );
--- a/yaccsrc/hornerarith.cc
+++ b/yaccsrc/hornerarith.cc
@@ -50,22 +50,21 @@
delete []pY;
delete []pX;
- delete pYpX;
- delete pYkx;
- delete pXkz;
+ delete []pYpX;
+ delete []pYkx;
+ delete []pXkz;
}
void hornerpolyxyz::setNull()
{
- pY=0;
+ pY=NULL;
- pYpX=0;
- pYkx=0;
+ pYpX=NULL;
+ pYkx=NULL;
pYn=0;
-
- pX=0;
+ pX=NULL;
- pXkz=0;
+ pXkz=NULL;
pXn=0;
}
--- a/yaccsrc/polyx.cc
+++ b/yaccsrc/polyx.cc
@@ -44,10 +44,10 @@
void polyx::allocCoeff (int size)
{
n = size;
- delete a;
+ delete []a;
a = new double [size+1];
- int i;
+ int i;
for( i = 0; i <= size; i++ ) {
a[i] = 0.0;
}
--- a/yaccsrc/polyx.h
+++ b/yaccsrc/polyx.h
@@ -47,22 +47,21 @@
/* ------------------------------------------------------------------------- */
-class polyx
+class polyx
{
private:
void operator= (const polyx &);
polyx (const polyx &p);
public:
- polyx() {n=0; a=0;};
- ~polyx() {delete a;}
+ polyx() {n=0; a=NULL;};
+ ~polyx() {delete []a;}
void allocCoeff (int size);
double horner (double x) const; // evaluate at x with horners method
double dx_horner (double x) const; // evaluate derivative at x with horners method
-
void fastDerive (polyx &derivative) const;
public:
--- a/src/RgbBuffer.cc
+++ b/src/RgbBuffer.cc
@@ -71,11 +71,10 @@
: width(0), height(0),
r( NULL ),
g( NULL ),
- b( NULL ),
+ b( NULL ),
map( NULL ),
curv( NULL),
-
- tag ( NULL ),
+ tag ( NULL ),
n(0),
nmap(0)
{
@@ -87,19 +86,27 @@
height(h),
r(new byte [w*h] ),
g(new byte [w*h] ),
- b(new byte [w*h] ),
- map(new byte [w*h] ),
+ b(new byte [w*h] ),
+ map(new byte [w*h] ),
curv(new byte[w*h] ),
-
- tag(new byte[w*h]),
- n(w*h),
- nmap(0)
+ tag(new byte[w*h]),
+ n(w*h),
+ nmap(0)
{
+ int i;
+
+ for( i=0; i<n; i++ ) {
+ r[i] = g[i] = b[i] = 0;
+ map[i] = 0;
+ curv[i] = 0;
+ tag[i] = 0;
+ }
+
}
// ----------------------------------------------------------------------------
-// release memory
+// release memory
// ----------------------------------------------------------------------------
RgbBuffer::~RgbBuffer()
{
@@ -108,7 +115,7 @@
delete [] b;
delete [] map;
delete [] curv;
- delete [] tag;
+ delete [] tag;
}
void RgbBuffer::clearTags()
@@ -130,27 +137,36 @@
// ----------------------------------------------------------------------------
void RgbBuffer::Realloc( int w, int h )
{
+ int i;
+
n = w * h;
width = w;
height = h;
-
delete [] r;
delete [] g;
delete [] b;
-
+
delete [] map;
delete [] curv;
-
- delete [] tag;
-
+
+ delete [] tag;
+
r = new byte [n];
g = new byte [n];
b = new byte [n];
map = new byte [n];
curv = new byte [n];
- tag = new byte [n];
+ tag = new byte [n];
+
+ for( i=0; i<n; i++ ) {
+ r[i] = g[i] = b[i] = 0;
+ map[i] = 0;
+ curv[i] = 0;
+ tag[i] = 0;
+ }
+
}
// ----------------------------------------------------------------------------
@@ -163,7 +179,7 @@
r[i] = f;
g[i] = f;
b[i] = f;
- curv[i] = f;
+ curv[i] = f;
}
return *this;
}
@@ -175,9 +191,9 @@
value2 = (value2>255) ? 255 : value2;
int i;
for( i=0; i<n; i++ ) {
- r[i] = (byte)value0;
- g[i] = (byte)value1;
- b[i] = (byte)value2;
+ r[i] = (byte)value0;
+ g[i] = (byte)value1;
+ b[i] = (byte)value2;
}
}
@@ -188,12 +204,10 @@
{
int i;
for( i=0; i<n; i++ ) {
- r[i] = 0;
- g[i] = 0;
- b[i] = 0;
+ r[i] = g[i] = b[i] = 0;
map[i] = 0;
- curv [i]= 0;
- tag[i] = 0;
+ curv[i] = 0;
+ tag[i] = 0;
}
}
@@ -204,21 +218,19 @@
{
int i;
for( i=0; i<n; i++ ) {
- r[i] = 0;
- g[i] = 0;
- b[i] = 0;
- tag[i]=0;
+ r[i] = g[i] = b[i] = 0;
+ tag[i] = 0;
}
}
// ----------------------------------------------------------------------------
-// set only second layer equal zero
+// set only second layer equal zero
// ----------------------------------------------------------------------------
void RgbBuffer::NullInit_two()
{
int i;
for( i=0; i<n; i++ ) {
- curv[i] = 0;
+ curv[i] = 0;
}
}
@@ -226,27 +238,25 @@
{
int i;
for( i=0; i<n; i++ ) {
- r[i] = 0;
- g[i] = 0;
- b[i] = 0;
+ r[i] = g[i] = b[i] = 0;
curv[i] = 0;
- tag[i] =0;
+ tag[i] = 0;
}
}
// ----------------------------------------------------------------------------
-// copy absolut values of a rgb buffer
+// copy absolut values of a rgb buffer
// ----------------------------------------------------------------------------
RgbBuffer& RgbBuffer::operator=( const RgbBuffer& a )
{
int i;
for( i=0; i < n; i++ ) {
- r[i] = (byte)abs( a.r[i] );
- g[i] = (byte)abs( a.g[i] );
- b[i] = (byte)abs( a.b[i] );
- map[i] = (byte)abs( a.map[i] );
- curv[i] = (byte)abs( a.curv[i] );
- tag[i] = (byte)abs( a.tag[i]);
+ r[i] = (byte)abs( a.r[i] );
+ g[i] = (byte)abs( a.g[i] );
+ b[i] = (byte)abs( a.b[i] );
+ map[i] = (byte)abs( a.map[i] );
+ curv[i] = (byte)abs( a.curv[i] );
+ tag[i] = (byte)abs( a.tag[i]);
}
return *this;
}
--- a/drawfunc/DrawfuncData.h
+++ b/drawfunc/DrawfuncData.h
@@ -30,7 +30,8 @@
#include <assert.h>
-#include "polyarith.h"
+//#include "polyarith.h"
+#include "MultiVariatePolynom.h"
#include "WindowGeometry.h"
@@ -65,7 +66,12 @@
}
void setGeometry (const WindowGeometry &wg)
- { wingeo = wg;};
+ {
+ wingeo = wg;
+ Delta[VARIABLE_X] = wg.getDelta( VARIABLE_X );
+ Delta[VARIABLE_Y] = wg.getDelta( VARIABLE_Y );
+ };
+
// draw curves or cutlines working x/y direction
--- a/drawfunc/DrawfuncData.cc
+++ b/drawfunc/DrawfuncData.cc
@@ -70,8 +70,8 @@
intensity(rgbbuff),
zbuffer(zbuff)
{
- Delta[VARIABLE_X] = GetDelta( VARIABLE_X );// coordinate distances
- Delta[VARIABLE_Y] = GetDelta( VARIABLE_Y );
+ Delta[VARIABLE_X] = 0.0/0.0; // wingeo not set up // GetDelta( VARIABLE_X ); // coordinate distances
+ Delta[VARIABLE_Y] = 0.0/0.0; // idem // GetDelta( VARIABLE_Y );
}
--- a/yaccsrc/Script.h
+++ b/yaccsrc/Script.h
@@ -98,6 +98,7 @@
private:
static void beforeScriptExecution();
static int internalExecuteScript (const char *str, bool runCommands=true);
+ static void afterScriptExecution();
protected:
// Commands....
--- a/drawfunc/DrawFunc.cc
+++ b/drawfunc/DrawFunc.cc
@@ -74,6 +74,22 @@
addCommand ("cut_with_plane", draw_func_cut);
}
+void draw_func_reinit_parser( void )
+{
+ if (draw_func_plane_data.n) {
+ delete_coeff_polyxyz( &draw_func_plane_data );
+ draw_func_plane_data.m = NULL;
+ draw_func_plane_data.deg = DEG_UNSPEC;
+ draw_func_plane_data.n = 0;
+ }
+ if (draw_func_function_data.n) {
+ delete_coeff_polyxyz( &draw_func_function_data );
+ draw_func_function_data.m = NULL;
+ draw_func_function_data.deg = DEG_UNSPEC;
+ draw_func_function_data.n = 0;
+ }
+}
+
// ----------------------------------------------------------------------------
// ---------------- draw a curve ----------------------------------------------
// ----------------------------------------------------------------------------
--- a/drawfunc/DrawFunc.h
+++ b/drawfunc/DrawFunc.h
@@ -34,11 +34,12 @@
#define CURVE_SHUTDOWN 3
#define CURVE_ZERO 4
#define CURVE_CONST 5
-#define CURVE_DEG_HIGH 6
+#define CURVE_DEG_HIGH 6
class Polyxyz;
void draw_func_init_parser( void );
+void draw_func_reinit_parser( void );
void draw_func_draw( void );
void draw_func_cut( void );
|