The OpenD Programming Language

mir_random_genRandomBlocking

Fills a buffer with random data. If not enough entropy has been gathered, it will block.

Note that on Mac OS X this method will never block.

extern (C) @nogc nothrow @system
ptrdiff_t
mir_random_genRandomBlocking
(
scope void* ptr
,
size_t len
)

Parameters

ptr void*

pointer to the buffer to fill

len size_t

length of the buffer (in bytes)

Return Value

Type: ptrdiff_t

A non-zero integer if an error occurred.

Examples

ubyte[] buf = new ubyte[10];
genRandomBlocking(buf);

int sum;
foreach (b; buf)
    sum += b;

assert(sum > 0, "Only zero points generated");

Meta