summaryrefslogtreecommitdiff
path: root/src/librandom/rrandom_add.c
blob: 23fa2afff32ec8caeb7c824d5d2956354b897600 (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 *z, int (*f) (unirandom *))
{
  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 ;
}