summaryrefslogtreecommitdiff
path: root/src/librandom/rrandom_add.c
blob: c22a43c6bf713176ef222283af82db4d7273a40e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
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 ;
}