[gimp] Bug 784961 - Undeclared identifier 'TIME_UTC' - GIMP fails to build...
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 784961 - Undeclared identifier 'TIME_UTC' - GIMP fails to build...
- Date: Sun, 16 Jul 2017 12:02:57 +0000 (UTC)
commit 93d2f49c164efe716fa0dbd1dab2faae947af802
Author: Michael Natterer <mitch gimp org>
Date: Sun Jul 16 14:01:18 2017 +0200
Bug 784961 - Undeclared identifier 'TIME_UTC' - GIMP fails to build...
...on macOS (with macports)
Changed gimp_metadata_get_guid() to use a GRand that automatically
seeds itself from /dev/urandom (if available) or the current time.
libgimpbase/gimpmetadata.c | 29 +++++++++++------------------
1 files changed, 11 insertions(+), 18 deletions(-)
---
diff --git a/libgimpbase/gimpmetadata.c b/libgimpbase/gimpmetadata.c
index 5024aa5..56fc8c7 100644
--- a/libgimpbase/gimpmetadata.c
+++ b/libgimpbase/gimpmetadata.c
@@ -206,29 +206,20 @@ gimp_metadata_init (GimpMetadata *metadata)
gchar *
gimp_metadata_get_guid (void)
{
- const int DALLOC = 36;
- struct timespec ts;
- long time;
- gint shake;
- gint bake;
- gchar *GUID;
- gchar *szHex;
-
- for (shake = 0; shake < 10; shake++)
- {
- timespec_get (&ts, TIME_UTC);
- time = ts.tv_nsec / 1000;
- srand (time);
- }
+ GRand *rand;
+ gint bake;
+ gchar *GUID;
+ const gchar *szHex = "0123456789abcdef-";
- GUID = g_malloc0 (DALLOC);
+ rand = g_rand_new ();
- bake = 0;
- szHex = "0123456789abcdef-";
+#define DALLOC 36
+
+ GUID = g_malloc0 (DALLOC);
for (bake = 0; bake < DALLOC; bake++)
{
- gint r = rand () % 16;
+ gint r = g_rand_int (rand) % 16;
gchar c = ' ';
switch (bake)
@@ -256,6 +247,8 @@ gimp_metadata_get_guid (void)
GUID[bake] = (bake < DALLOC) ? c : 0x00;
}
+ g_rand_free (rand);
+
return GUID;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]