Merge "Add types to Device::SubClass" into devel/master
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 10 Oct 2017 15:16:37 +0000 (15:16 +0000)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Tue, 10 Oct 2017 15:16:37 +0000 (15:16 +0000)
dali/public-api/math/random.h

index 8067112..2e8391e 100644 (file)
@@ -48,6 +48,16 @@ inline float Range(float f0, float f1)
 {
   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);
 }