Use base::Split to replace tokenize() function.
Test: libvintf_test
Test: vintf_object_test
Change-Id: I8a416d8690162c1ee84c02aad01501b6ccb6b43f
diff --git a/AssembleVintf.cpp b/AssembleVintf.cpp
index a624157..4665f68 100644
--- a/AssembleVintf.cpp
+++ b/AssembleVintf.cpp
@@ -25,6 +25,7 @@
#include <android-base/file.h>
#include <android-base/parseint.h>
+#include <android-base/strings.h>
#include <vintf/AssembleVintf.h>
#include <vintf/KernelConfigParser.h>
@@ -633,7 +634,7 @@
}
bool AssembleVintf::addKernel(const std::string& kernelArg) {
- auto tokens = details::tokenize(kernelArg);
+ auto tokens = base::Split(kernelArg, ":");
if (tokens.size() <= 1) {
std::cerr << "Unrecognized --kernel option '" << kernelArg << "'" << std::endl;
return false;
diff --git a/assemble_vintf_main.cpp b/assemble_vintf_main.cpp
index c43f831..45e6dc2 100644
--- a/assemble_vintf_main.cpp
+++ b/assemble_vintf_main.cpp
@@ -18,6 +18,7 @@
#include <iostream>
+#include <android-base/strings.h>
#include <vintf/AssembleVintf.h>
#include "utils.h"
@@ -76,7 +77,7 @@
while ((res = getopt_long(argc, argv, "hi:o:mc:nl", longopts, &optind)) >= 0) {
switch (res) {
case 'i': {
- for (const auto& inFilePath : details::tokenize(optarg)) {
+ for (const auto& inFilePath : ::android::base::Split(optarg, ":")) {
if (!assembleVintf->openInFile(inFilePath.c_str())) {
std::cerr << "Failed to open " << inFilePath << std::endl;
return 1;
diff --git a/utils.cpp b/utils.cpp
index 3a5122e..2b0cb37 100644
--- a/utils.cpp
+++ b/utils.cpp
@@ -29,19 +29,6 @@
static ObjectFactory<RuntimeInfo> runtimeInfoFactory;
ObjectFactory<RuntimeInfo>* gRuntimeInfoFactory = &runtimeInfoFactory;
-std::vector<std::string> tokenize(const std::string& s, const char* delimiters) {
- char* modString = new char[s.length() + 1];
- strcpy(modString, s.c_str());
- std::vector<std::string> ret;
- char* e = strtok(modString, delimiters);
- while (e != NULL) {
- ret.push_back(e);
- e = strtok(NULL, delimiters);
- }
- delete[] modString;
- return ret;
-}
-
} // namespace details
} // namespace vintf
} // namespace android
diff --git a/utils.h b/utils.h
index a117e88..dce03b3 100644
--- a/utils.h
+++ b/utils.h
@@ -107,8 +107,6 @@
};
extern ObjectFactory<RuntimeInfo>* gRuntimeInfoFactory;
-std::vector<std::string> tokenize(const std::string& s, const char* delimiters = ":");
-
} // namespace details
} // namespace vintf
} // namespace android