DrylandEcology / SOILWAT2

An ecosystem water balance simulation model
GNU General Public License v3.0
5 stars 2 forks source link

Replace `strtok()` with a thread-safe function #376

Closed dschlaep closed 8 months ago

dschlaep commented 8 months ago

strtok() is not thread-safe because it modifies a static variable (https://en.cppreference.com/w/c/string/byte/strtok).

We currently use it in getfiles(), MkDir(), and _create_filename_ST(). It seems that we use getfiles() and MkDir() only in SW_F_read() via SW_CSV_F_INIT().

Replacing with strtok_s() is not ideal it was introduced with C11 (but STEPWAT2 uses C99) and extension 1 may not be implemented.