re-entrant strtok(), strdup() and free()