mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
random: use void * in random_bytes()
This commit is contained in:
parent
23d8e9c085
commit
1e69740d18
@ -82,7 +82,7 @@ uint32_t random_uint32(void);
|
||||
/**
|
||||
* @brief writes random bytes in the [0,0xff]-interval to memory
|
||||
*/
|
||||
void random_bytes(uint8_t *buf, size_t size);
|
||||
void random_bytes(void *buf, size_t size);
|
||||
|
||||
/**
|
||||
* @brief generates a random number r with a <= r < b.
|
||||
|
@ -60,9 +60,10 @@ void auto_init_random(void)
|
||||
random_init(seed);
|
||||
}
|
||||
|
||||
void random_bytes(uint8_t *target, size_t n)
|
||||
void random_bytes(void *target, size_t n)
|
||||
{
|
||||
uint32_t random;
|
||||
uint8_t *dst = target;
|
||||
uint8_t *random_pos = (uint8_t*)&random;
|
||||
unsigned _n = 0;
|
||||
|
||||
@ -71,7 +72,7 @@ void random_bytes(uint8_t *target, size_t n)
|
||||
random = random_uint32();
|
||||
random_pos = (uint8_t *) &random;
|
||||
}
|
||||
*target++ = *random_pos++;
|
||||
*dst++ = *random_pos++;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user