/soc/2012/sanket/statscollector-2.x.y: b519e30e98df: Use inbuilt...
Sanket Agarwal
sanket at soc.pidgin.im
Tue Jul 10 00:36:26 EDT 2012
Changeset: b519e30e98df04697aaaf3839a2def89cee4bf18
Author: Sanket Agarwal <sanket at soc.pidgin.im>
Date: 2012-06-05 17:50 +0000
Branch: soc.2012.statscollector
URL: http://hg.pidgin.im/soc/2012/sanket/statscollector-2.x.y/rev/b519e30e98df
Description:
Use inbuilt purple_uuid_random instead of own implementation
I was too naive to be using a hand woven (and rather clumsy) implementation
of creating a 128bit random string. Pidgin already has an implementation of
uuid4 random generation.
diffstat:
libpurple/plugins/statscollector.c | 34 ++++++----------------------------
1 files changed, 6 insertions(+), 28 deletions(-)
diffs (51 lines):
diff --git a/libpurple/plugins/statscollector.c b/libpurple/plugins/statscollector.c
--- a/libpurple/plugins/statscollector.c
+++ b/libpurple/plugins/statscollector.c
@@ -69,33 +69,6 @@
}
-static char *
-rand_md5(){
-
- char e[] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
- char *rand_str;
- int i;
- GTimeVal time;
-
- g_get_current_time(&time);
-
- /* Creates a random MD5 (16bytes) string */
- rand_str = (char *)g_new0(char, 16*2+1);
-
- /* Initialize the seed */
- srand(time.tv_sec * time.tv_usec);
-
- /* Randomly fill it */
- for(i=0;i<32;i++){
- rand_str[i] = e[rand()%16];
- }
-
- rand_str[i] = '\0';
-
- return rand_str;
-
-}
-
static void
save_xml(){
@@ -993,7 +966,12 @@
purple_prefs_add_int("/plugins/core/statscollector/last-sent", 0);
/* A random 16 byte string for identifying unique machines */
- purple_prefs_add_string("/plugins/core/statscollector/send-key", rand_md5());
+ /* Unsure whether rand() is called when pidgin initializes
+ * it on startup
+ */
+ g_rand_new_with_seed(time(NULL));
+ purple_prefs_add_string("/plugins/core/statscollector/send-key", \
+ purple_uuid_random());
}
PURPLE_INIT_PLUGIN(statscollector, init_plugin, info)
More information about the Commits
mailing list