- For security, the random number generator would be initialized
to use rand().
Change-Id: I6930001c41001ec217bf706d84dc15b71a17d1fe
Signed-off-by: Seoyeon Kim <seoyeon2.kim@samsung.com>
{
float min = std::min(f0, f1);
float max = std::max(f0, f1);
+
+ // Ensure we initialize only once. As it's inlined, this static variable will exist in the code-block using it, thus,
+ // will be created and then initialized again when another code-block uses this.
+ static bool initialized( false );
+ if( !initialized )
+ {
+ srand( time( NULL ) );
+ initialized = true;
+ }
+
return min + (rand() & 0xfff) * (max-min) * (1.0f/4095.0f);
}