]> git.sesse.net Git - vlc/commitdiff
rand_s() is only in Win XP and latest. so use rand() until we decide to not support...
authorChristophe Mutricy <xtophe@videolan.org>
Sat, 1 Sep 2007 21:44:12 +0000 (21:44 +0000)
committerChristophe Mutricy <xtophe@videolan.org>
Sat, 1 Sep 2007 21:44:12 +0000 (21:44 +0000)
src/misc/rand.c

index 9e27ced3b0bb975df5d4be73b5b53c1c5ae19c64..0caa83a99a5a64b51ea818e0462dfff01450edf4 100644 (file)
@@ -116,7 +116,9 @@ void vlc_rand_bytes (void *buf, size_t len)
 }
 
 #else /* WIN32 */
-#define _CRT_RAND_S
+/* It would be better to use rand_s() instead of rand() but it's not possible 
+ * while we support Win 2OOO and until it gets included in mingw */
+/* #define _CRT_RAND_S*/
 #include <stdlib.h>
 
 void vlc_rand_bytes (void *buf, size_t len)
@@ -124,7 +126,8 @@ void vlc_rand_bytes (void *buf, size_t len)
     while (len > 0)
     {
         unsigned int val;
-        rand_s (&val);
+        /*rand_s (&val);*/
+        val = rand();
 
         if (len < sizeof (val))
         {
@@ -133,6 +136,7 @@ void vlc_rand_bytes (void *buf, size_t len)
         }
 
         memcpy (buf, &val, sizeof (val));
+        len -= sizeof (val);
     }
 }
 #endif