summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristophe Fergeau <teuf@gnome.org>2005-10-14 09:42:05 +0000
committerChristophe Fergeau <teuf@gnome.org>2005-10-14 09:42:05 +0000
commit26607a3dfc37622a0303cfbb9b854378cb72158f (patch)
treede2be82f881d398313036f8cea55ba6a8056afd7 /src
parent1bdf691f8f1ee181089d0e1fb42681e5346e8783 (diff)
downloadlibgpod-26607a3dfc37622a0303cfbb9b854378cb72158f.tar.gz
libgpod-26607a3dfc37622a0303cfbb9b854378cb72158f.tar.xz
libgpod-26607a3dfc37622a0303cfbb9b854378cb72158f.zip
2005-10-14 Christophe Fergeau <teuf@gnome.org>
* src/itdb_itunesdb.c: (itdb_new): * src/itdb_playlist.c: (itdb_playlist_add): * src/itdb_track.c: (itdb_track_set_defaults): Use g_random_int instead of g_rand_int, this avoids a potential leak of the GRand seed used for g_rand_int. git-svn-id: https://gtkpod.svn.sf.net/svnroot/gtkpod/libgpod/trunk@1120 f01d2545-417e-4e96-918e-98f8d0dbbcb6
Diffstat (limited to 'src')
-rw-r--r--src/itdb_itunesdb.c7
-rw-r--r--src/itdb_playlist.c5
-rw-r--r--src/itdb_track.c5
3 files changed, 6 insertions, 11 deletions
diff --git a/src/itdb_itunesdb.c b/src/itdb_itunesdb.c
index 76c9660..a069551 100644
--- a/src/itdb_itunesdb.c
+++ b/src/itdb_itunesdb.c
@@ -891,13 +891,10 @@ guint32 itdb_tracks_number_nontransferred (Itdb_iTunesDB *itdb)
values */
Itdb_iTunesDB *itdb_new (void)
{
- GRand *grand = g_rand_new ();
-
Itdb_iTunesDB *itdb = g_new0 (Itdb_iTunesDB, 1);
itdb->version = 0x09;
- itdb->id = ((guint64)g_rand_int (grand) << 32) |
- ((guint64)g_rand_int (grand));
- g_rand_free (grand);
+ itdb->id = ((guint64)g_random_int () << 32) |
+ ((guint64)g_random_int ());
return itdb;
}
diff --git a/src/itdb_playlist.c b/src/itdb_playlist.c
index b09bb81..e48ed8a 100644
--- a/src/itdb_playlist.c
+++ b/src/itdb_playlist.c
@@ -1069,13 +1069,12 @@ void itdb_playlist_add (Itdb_iTunesDB *itdb, Itdb_Playlist *pl, gint32 pos)
/* set unique ID when not yet set */
if (pl->id == 0)
{
- GRand *grand = g_rand_new ();
GList *gl;
guint64 id;
do
{
- id = ((guint64)g_rand_int (grand) << 32) |
- ((guint64)g_rand_int (grand));
+ id = ((guint64)g_random_int () << 32) |
+ ((guint64)g_random_int ());
/* check if id is really unique (with 100 playlists the
* chance to create a duplicate is 1 in
* 184,467,440,737,095,516.16) */
diff --git a/src/itdb_track.c b/src/itdb_track.c
index dbfd487..14ff740 100644
--- a/src/itdb_track.c
+++ b/src/itdb_track.c
@@ -132,13 +132,12 @@ static void itdb_track_set_defaults (Itdb_Track *tr)
/* set unique ID when not yet set */
if (tr->dbid == 0)
{
- GRand *grand = g_rand_new ();
GList *gl;
guint64 id;
do
{
- id = ((guint64)g_rand_int (grand) << 32) |
- ((guint64)g_rand_int (grand));
+ id = ((guint64)g_random_int () << 32) |
+ ((guint64)g_random_int ());
/* check if id is really unique */
for (gl=tr->itdb->tracks; id && gl; gl=gl->next)
{