aboutsummaryrefslogtreecommitdiff
path: root/km-rand.c
diff options
context:
space:
mode:
Diffstat (limited to 'km-rand.c')
-rw-r--r--km-rand.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/km-rand.c b/km-rand.c
index fcc6a74..1410861 100644
--- a/km-rand.c
+++ b/km-rand.c
@@ -12,6 +12,16 @@ km_rand_fill(
return rs->cbs->fill(rs, num_floats, floats);
}
+// fill buffer with N random size_ts
+bool
+km_rand_fill_sizes(
+ km_rand_t * const rs,
+ const size_t num_sizes,
+ size_t * const sizes
+) {
+ return rs->cbs->fill_sizes(rs, num_sizes, sizes);
+}
+
// finalize random source
void
km_rand_fini(
@@ -40,11 +50,30 @@ system_on_fill(
return true;
}
+// fill sizes callback for system random source
+static bool
+system_on_fill_sizes(
+ km_rand_t * const rs,
+ const size_t num_sizes,
+ size_t * const sizes
+) {
+ UNUSED(rs);
+
+ // generate random size_ts
+ for (size_t i = 0; i < num_sizes; i++) {
+ sizes[i] = rand();
+ }
+
+ // return success
+ return true;
+}
+
// system random source callbacks
static const km_rand_cbs_t
SYSTEM_CBS = {
- .fill = system_on_fill,
- .fini = NULL,
+ .fill = system_on_fill,
+ .fill_sizes = system_on_fill_sizes,
+ .fini = NULL,
};
// init system random source (uses system rand())