summaryrefslogtreecommitdiff
path: root/src/librandom/rrandom_add.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/librandom/rrandom_add.c')
-rw-r--r--src/librandom/rrandom_add.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/librandom/rrandom_add.c b/src/librandom/rrandom_add.c
new file mode 100644
index 0000000..c22a43c
--- /dev/null
+++ b/src/librandom/rrandom_add.c
@@ -0,0 +1,13 @@
+/* ISC license. */
+
+#include <errno.h>
+#include <skalibs/unirandom.h>
+#include <skalibs/rrandom.h>
+
+int rrandom_add (rrandom_ref z, int (*f) (unirandom_ref))
+{
+ if (z->n >= 3) return (errno = EBUSY, 0) ;
+ if (!(*f)(&z->tries[z->n].it)) return 0 ;
+ z->tries[z->n++].ok = 3 ;
+ return 1 ;
+}