Re: [Tuxracer-devel] too many Particles and libtcl8.x
Status: Beta
Brought to you by:
jfpatry
From: Jasmin P. <jf...@mu...> - 2000-02-29 03:52:21
|
To follow up on the particle system bug: If you can reliably re-create the problem, could you please apply the attached patch to part_sys.c and send me the resulting core file? Please also specify your compiler version (I'm assuming I'll need to use the same version to use your core file, or no? I'm new to distributed development. :-). By the way, if you want to suppress particle generation altogether, simply comment out the call to generate_particles() in phys_sim.c. Thanks, Jasmin *** part_sys.c.0.10 Mon Feb 28 22:12:40 2000 --- part_sys.c Mon Feb 28 22:32:56 2000 *************** *** 23,28 **** --- 23,32 ---- #include "phys_sim.h" #include "gl_util.h" + /* This constant is here as part of a debugging check to prevent an infinite + number of particles from being created */ + #define MAX_PARTICLES 100000 + #define START_RADIUS 0.1 #define PART_SIZE 0.07 #define PART_SPEED 1.3 *************** *** 40,45 **** --- 44,50 ---- static colour_t partColour = { 0.69, 0.72, 0.906 }; static Particle* head = NULL; + static int num_particles = 0; scalar_t frand() { *************** *** 51,59 **** --- 56,82 ---- Particle *newp; int i; + /* Debug check to track down infinite particle bug */ + if ( num_particles > MAX_PARTICLES ) { + fprintf( stderr, + "tuxracer: Maximum number of particles exceeded.\n" + "*** Please help the Tux Racer developers by emailing the core file \n" + "*** that has just been created (gzip it first, please) to \n" + "*** <jf...@cg...>. Thanks!\n"); + assert( 0 ); + } + for (i=0; i<num; i++) { newp = (Particle*)malloc( sizeof( Particle) ); + + if ( newp == NULL ) { + fprintf( stderr, "tuxracer: Out of memory.\n" ); + exit( -1 ); + } + + num_particles += 1; + newp->next = head; head = newp; *************** *** 108,113 **** --- 131,137 ---- q = *p; *p = q->next; free(q); + num_particles -= 1; continue; } *************** *** 150,153 **** --- 174,178 ---- free(q); } head = NULL; + num_particles = 0; } |