mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-09-19 13:30:02 +00:00
printing: Avoid getrandom
GLib has perfectly serviceable random number apis, and this breaks the macOs build.
This commit is contained in:
parent
da8a1f4683
commit
06d3bbafaf
@ -19,7 +19,6 @@
|
||||
|
||||
|
||||
#include <glib.h>
|
||||
#include <sys/random.h>
|
||||
|
||||
#include "gtkprintbackendutils.h"
|
||||
|
||||
@ -114,15 +113,13 @@ random_string (int n)
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
"0123456789";
|
||||
|
||||
char *str = g_new0 (char, n+1);
|
||||
getrandom (str, n, 0);
|
||||
for (int i=0; i<n; i++)
|
||||
char *str = g_new0 (char, n + 1);
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
int rand = str[i] + 128;
|
||||
int idx = rand % ((int) sizeof charset);
|
||||
int idx = g_random_int_range (0, strlen (charset));
|
||||
str[i] = charset[idx];
|
||||
}
|
||||
str[n] = '\0';
|
||||
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user