libsvm
libsvm copied to clipboard
Remove uses of strtok() and other global state in svm_load_model().
strtok() (as well as the internal readline() function) used global state, and therefore were not thread-safe. Replace them with reentrant equivalents. Thread-safety of loading was checked with valgrind's helgrind and drd tools.
As an added bonus, the new tokenization functions are much faster than strtok(). In a benchmark with a large model, overall loading time decreased by 45% (1.1s vs 1.9s over 32 trials).