1 #ifndef _GOOMTOOLS_H 2 #define _GOOMTOOLS_H 3 4 #define NB_RAND 0x10000 5 6 #define RAND_INIT(gd,i) \ 7 srand (i); \ 8 if (gd->rand_tab == NULL) \ 9 gd->rand_tab = g_malloc (NB_RAND * sizeof(gint)) ;\ 10 gd->rand_pos = 0; \ 11 while (gd->rand_pos < NB_RAND) \ 12 gd->rand_tab [gd->rand_pos++] = rand (); 13 14 #define RAND(gd) \ 15 (gd->rand_tab[gd->rand_pos = ((gd->rand_pos + 1) % NB_RAND)]) 16 17 #define RAND_CLOSE(gd) \ 18 g_free (gd->rand_tab); \ 19 gd->rand_tab = NULL; 20 21 /*#define iRAND(i) ((guint32)((float)i * RAND()/RAND_MAX)) */ 22 #define iRAND(gd,i) (RAND(gd) % i) 23 24 #endif 25