AFAIK any reentrant function is thread-safe. So, as long as I keep my
library functions reentrant there are no problems.
I think there might some weird corner-cases of
reentrant-but-not-threadsafe functions (the language lawyers here will
surely know), but basically, yes, if it's reentrant then it's going to
be threadsafe.
Unfortunately there are no standard c functions to allocate dynamic
memory that are assured to be reentrant. Is everything correct?
That's complete nonsense. The regulars here might worry about such
abysmal QoI on their DeathStations, but in practice all the threads
libraries you're ever likely to use will provide threadsafe malloc(),
stdio functions, and everything else you need to program C in a
multithreaded environment. If you apply some common sense (again, unlike
the regulars), what would be the point of providing a threads
implementation for C where the programmer couldn't safely do something
as fundamental as allocate memory?
For example, in the GNU setup, the C library behaves differently when
you link against libpthread: malloc becomes threadsafe (but slower),
fork does the necessary things to pass on the thread setup to the child
process it creates, and so on. I believe other Unices add extra
reentrant versions of standard library functions, e.g. strtok_r and the
like.
Don't be paralyzed by the regulars' paranoia.