3 ms·
The existence of strtok_r() is weird anyway. If we can make errno thread-safe, there is no reason why plain strtok() can't be thread-safe. The idea that somebod
by souprock 6y ago
The existence of strtok_r() is weird anyway. If we can make errno thread-safe, there is no reason why plain strtok() can't be thread-safe. The idea that somebody wants strtok() state shared across threads is just as weird as the idea that errno should be shared across threads.
- kevin_thibedeau 6y agoThe C API was never designed with threading in mind. Not all platforms support threads so the old behavior must stay around.
- souprock 6y agoSay what? You like to call plain strtok() from different threads, having them all update a shared global state? I think you missed the point here, because that would be some really evil usage of the strtok() function. We had "int errno" as global state. We fixed it, in a compatible way, to be thread-safe. Platforms without threads can still implement it the old way if desired. The same kind of compatible fix could have been done with the strtok() function. There was no need to introduce another function. Simply: the internal state of strtok() shall be distinct for each thread. (which is trivial if the platform only supports a single thread)