summaryrefslogtreecommitdiff
path: root/src/modules/spiro
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2022-05-21 23:27:02 -0700
committerVito Caputo <vcaputo@pengaru.com>2022-05-21 23:27:02 -0700
commitc1fed8c508dd89c86de7dd647de0d014c441344e (patch)
treefac4d327c18fe5a2a205a2f4b4ad7f8287ec3536 /src/modules/spiro
parente21cdb67718a5d203372fd0c425e8be3e1d273f3 (diff)
modules/*: first stab at utilizing supplied seeds
This is a mostly mechanical change of using rand_r() in place of rand(), using the provided seed as the seed state. There's some outstanding rand()s outside of create_context() which should probably get switched over, with the seed being stowed in the context struct. I didn't bother going deeper on this at the moment in the interests of getting to sleep soon.
Diffstat (limited to 'src/modules/spiro')
-rw-r--r--src/modules/spiro/spiro.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/modules/spiro/spiro.c b/src/modules/spiro/spiro.c
index 07d9fbf..a2adb7b 100644
--- a/src/modules/spiro/spiro.c
+++ b/src/modules/spiro/spiro.c
@@ -38,12 +38,12 @@ static void * spiro_create_context(unsigned seed, unsigned ticks, unsigned n_cpu
if (!ctxt)
return NULL;
- ctxt->r=.25f+(rand()/(float)RAND_MAX)*.5f;
+ ctxt->r=.25f+(rand_r(&seed)/(float)RAND_MAX)*.5f;
if(ctxt->r>.5f)
ctxt->r_dir=-1;
else
ctxt->r_dir=1;
- ctxt->p=(rand()/(float)RAND_MAX)*ctxt->r;
+ ctxt->p=(rand_r(&seed)/(float)RAND_MAX)*ctxt->r;
ctxt->p_dir=ctxt->r_dir*-1;
#ifdef DEBUG
printf("spiro: initial context: r=%f, dir=%i, p=%f, dir=%i\n", ctxt->r, ctxt->r_dir, ctxt->p, ctxt->p_dir);
© All Rights Reserved