News for hackers. Stuff that matters.
Re:String tokenization in C by heinrichhartman on Saturday December 15, 2018 @07:42AM (#18688158)
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?
Re:String tokenization in C by nly on Saturday December 15, 2018 @08:56AM (#18688388)
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.

Re:String tokenization in C by Sharlin on Saturday December 15, 2018 @07:53AM (#18688188)
Yes, as long as you can guarantee that there’s only one tokenization going on per thread at a time.