> Strtok is not thread safe and can’t be made thread safe without changing the API. You should not use it.
Well, there is already a thread-safe variant [0]:
> The strtok() function uses a static buffer while parsing, so it's not thread safe. Use strtok_r() if this matters to you.
Well, strtok could use thread local variables to store intermediate state, to make it threadsafe while maintaining the same API. Not saying this is a good idea, but technically it would work, no?
You could, but that would change the behaviour of existing programs. It might well be that there are well-defined programs out there that use strtok across separate, but properly synchronized, threads.
This is why it's crucial to get APIs right first time.
Maybe he means that the function is not re-entrant. You cannot run a loop that tokenizes a string, and somewhere inside, you call a function that uses strtok itself. This can happen inadvertently.