breakin a srand usage
This commit is contained in:
		
							parent
							
								
									39903d1067
								
							
						
					
					
						commit
						56941f1215
					
				@ -450,13 +450,9 @@ int	set_new_seed(int k)
 | 
				
			|||||||
char		*ptr;
 | 
					char		*ptr;
 | 
				
			||||||
long		seed;
 | 
					long		seed;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if DEBUG_MESSAGE
 | 
					 | 
				
			||||||
if (k)	fprintf(stderr, "%s: k %d\n", __func__, k); 
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
if (NULL==(ptr=getenv("FIXED_SEED"))) {
 | 
					if (NULL==(ptr=getenv("FIXED_SEED"))) {
 | 
				
			||||||
	/* no fixed seed in context, doing semi-random */
 | 
						/* no fixed seed in context, doing semi-random */
 | 
				
			||||||
	srand(getpid());
 | 
						srand(getpid() + k);
 | 
				
			||||||
#if DEBUG_LEVEL
 | 
					#if DEBUG_LEVEL
 | 
				
			||||||
	fprintf(stderr, "no FIXED_SEED, first rand is number : %d\n", rand());
 | 
						fprintf(stderr, "no FIXED_SEED, first rand is number : %d\n", rand());
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
@ -464,10 +460,6 @@ if (NULL==(ptr=getenv("FIXED_SEED"))) {
 | 
				
			|||||||
else	{
 | 
					else	{
 | 
				
			||||||
	/* try to parse the env var */
 | 
						/* try to parse the env var */
 | 
				
			||||||
	seed = strtol(ptr, NULL, 0);
 | 
						seed = strtol(ptr, NULL, 0);
 | 
				
			||||||
#if DEBUG_LEVEL
 | 
					 | 
				
			||||||
	fprintf(stderr, "%s : strtol(%s) -> %ld\n",
 | 
					 | 
				
			||||||
				__func__, ptr, seed);
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
	srand(seed);
 | 
						srand(seed);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user