Lots of work on removing malloc from driver

This commit is contained in:
2022-02-17 20:02:08 -05:00
parent 9d7bf8b0f9
commit 467f25b927
17 changed files with 1301 additions and 197 deletions

View File

@@ -269,18 +269,6 @@ double strtodouble(const std::string &value) {
}
}
void split_host_port(const std::string &target, std::string &host, std::string &port) {
size_t lastcolon = target.rfind(':');
if (lastcolon == std::string::npos) {
host = ""; port = ""; return;
}
host = target.substr(0, lastcolon);
port = target.substr(lastcolon + 1);
if ((host == "") || (port == "")) {
host = ""; port = ""; return;
}
}
std::string ltrim(std::string s) {
s.erase(s.begin(), std::find_if(s.begin(), s.end(),
std::not1(std::ptr_fun<int, int>(std::isspace))));
@@ -436,12 +424,6 @@ LuaDefine(unittests_util, "", "some unit tests") {
LuaAssert(L, std::isnan(util::strtodouble("12ab")));
LuaAssert(L, std::isnan(util::strtodouble("")));
// Test split_host_port
std::string host, port;
util::split_host_port("stanford.edu:80", host, port);
LuaAssertStrEq(L, host, "stanford.edu");
LuaAssertStrEq(L, port, "80");
// Test trim, ltrim, rtrim
LuaAssert(L, util::ltrim(" foo ") == "foo ");
LuaAssert(L, util::rtrim(" foo ") == " foo");