[gmime] Only initialize srand() once on Windows/Mac



commit 3d13e07155c7609fc4e46c88cd8615850f094f19
Author: Jeffrey Stedfast <jestedfa microsoft com>
Date:   Wed Aug 31 09:50:28 2016 -0400

    Only initialize srand() once on Windows/Mac
    
    2016-08-30  Jeffrey Stedfast  <fejj gnome org>
    
        * gmime/gmime-multipart.c (read_random_pool): Only initialized srand() once.

 ChangeLog               |    4 ++++
 gmime/gmime-multipart.c |    6 +++++-
 2 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 573dcbf..d641cf7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2016-08-30  Jeffrey Stedfast  <fejj gnome org>
+
+       * gmime/gmime-multipart.c (read_random_pool): Only initialized srand() once.
+
 2016-07-19  Jeffrey Stedfast  <jeff xamarin com>
 
        * gmime/gmime-gpg-context.c (gpg_ctx_get_argv): Always use --batch mode and
diff --git a/gmime/gmime-multipart.c b/gmime/gmime-multipart.c
index 7b85848..fde17d0 100644
--- a/gmime/gmime-multipart.c
+++ b/gmime/gmime-multipart.c
@@ -708,9 +708,13 @@ read_random_pool (unsigned char *buffer, size_t bytes)
        
        close (fd);
 #else
+       static gboolean srand_initialized = FALSE;
        size_t i;
        
-       srand ((unsigned int) time (NULL));
+       if (!srand_initialized) {
+               srand ((unsigned int) time (NULL));
+               srand_initialized = TRUE;
+       }
        
        for (i = 0; i < bytes; i++)
                buffer[i] = (unsigned char) (rand () % 256);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]