Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
ufo
on April 9, 2022
|
parent
|
context
|
favorite
| on:
rand() may call malloc()
Does anyone know why the reentrancy layer needed malloc in the first place? I didn't understand that part.
saagarjha
on April 9, 2022
[–]
It's used to store internal random state.
ufo
on April 9, 2022
|
parent
[–]
But why is the internal RNG state dynamically allocated? I would have expected it to be a static variable allocated only once.
veltas
on April 9, 2022
|
root
|
parent
[–]
So that you can call it in different threads or in a signal without clobbering another invocation's state.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: