4 ms·
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,
by heinrichhartman 8y ago
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?
- Sharlin 8y agoYes, as long as you can guarantee that there’s only one tokenization going on per thread at a time.
- deleted 8y ago[deleted]
- nly 8y agoYou 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.