< prev index next >

src/hotspot/share/compiler/compilerDirectives.cpp

Print this page
rev 52814 : 8214773: Replace use of thread unsafe strtok
Reviewed-by:

@@ -28,10 +28,11 @@
 #include "compiler/abstractCompiler.hpp"
 #include "compiler/compilerDirectives.hpp"
 #include "compiler/compilerOracle.hpp"
 #include "memory/allocation.inline.hpp"
 #include "memory/resourceArea.hpp"
+#include "runtime/os.inline.hpp"
 
 CompilerDirectives::CompilerDirectives() : _next(NULL), _match(NULL), _ref_count(0) {
   _c1_store = new DirectiveSet(this);
   _c2_store = new DirectiveSet(this);
 };

@@ -397,16 +398,17 @@
   // ',' as a separator.
   size_t length = strlen(DisableIntrinsicOption);
   char* local_list = NEW_RESOURCE_ARRAY(char, length + 1);
   strncpy(local_list, DisableIntrinsicOption, length + 1);
 
-  char* token = strtok(local_list, ",");
+  char *save_ptr;
+  char* token = os::strtok(local_list, ",", &save_ptr);
   while (token != NULL) {
     if (strcmp(token, vmIntrinsics::name_at(id)) == 0) {
       return true;
     } else {
-      token = strtok(NULL, ",");
+      token = os::strtok(NULL, ",", &save_ptr);
     }
   }
 
   return false;
 }
< prev index next >