[libsoup/gtimeval-out: 3/3] SoupMultipart: remove usage of GTimeVal and g_get_current_time()



commit 47539f8ffdbfa5412d3dd0b23c4b92c3a23716b3
Author: Claudio Saavedra <csaavedra igalia com>
Date:   Tue Aug 13 15:22:46 2019 +0300

    SoupMultipart: remove usage of GTimeVal and g_get_current_time()
    
    Use a hash of the current time via GDateTime instead.

 libsoup/soup-multipart.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/libsoup/soup-multipart.c b/libsoup/soup-multipart.c
index 242c632f..f4dc00e9 100644
--- a/libsoup/soup-multipart.c
+++ b/libsoup/soup-multipart.c
@@ -61,18 +61,21 @@ soup_multipart_new_internal (char *mime_type, char *boundary)
 static char *
 generate_boundary (void)
 {
-       static int counter;
+       GDateTime *datetime;
+
        struct {
-               GTimeVal timeval;
-               int counter;
+               guint hash;
+               guint32 salt;
        } data;
 
        /* avoid valgrind warning */
-       if (sizeof (data) != sizeof (data.timeval) + sizeof (data.counter))
+       if (sizeof (data) != sizeof (data.hash) + sizeof (data.salt))
                memset (&data, 0, sizeof (data));
 
-       g_get_current_time (&data.timeval);
-       data.counter = counter++;
+       datetime = g_date_time_new_now_local ();
+       data.hash = g_date_time_hash (datetime);
+       data.salt = g_random_int ();
+       g_date_time_unref (datetime);
 
        /* The maximum boundary string length is 69 characters, and a
         * stringified SHA256 checksum is 64 bytes long.


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