Merge pull request #3620 from LDOUBLEV/fix_cpp_22

fix cpp
This commit is contained in:
Double_V 2021-08-09 20:44:48 +08:00 committed by GitHub
commit d585f4c5dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -21,10 +21,12 @@ std::vector<std::string> OCRConfig::split(const std::string &str,
std::vector<std::string> res; std::vector<std::string> res;
if ("" == str) if ("" == str)
return res; return res;
char strs[str.length() + 1]; int strlen = str.length() + 1;
char *strs = new char[strlen];
std::strcpy(strs, str.c_str()); std::strcpy(strs, str.c_str());
char d[delim.length() + 1]; int delimlen = delim.length() + 1;
char *d = new char[delimlen];
std::strcpy(d, delim.c_str()); std::strcpy(d, delim.c_str());
char *p = std::strtok(strs, d); char *p = std::strtok(strs, d);
@ -34,6 +36,8 @@ std::vector<std::string> OCRConfig::split(const std::string &str,
p = std::strtok(NULL, d); p = std::strtok(NULL, d);
} }
delete[] strs;
delete[] d;
return res; return res;
} }