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

@@ -0,0 +1,29 @@
#include "driver-util.hpp"
#include "luastack.hpp"
namespace drv {
void split_host_port(std::string_view target, UmmString &host, UmmString &port) {
size_t lastcolon = target.rfind(':');
if (lastcolon == std::string_view::npos) {
host = ""; port = ""; return;
}
host = target.substr(0, lastcolon);
port = target.substr(lastcolon + 1);
if ((host == "") || (port == "")) {
host = ""; port = ""; return;
}
}
} // namespace drv
LuaDefine(unittests_driverutil, "", "some unit tests") {
// Test split_host_port
UmmString host, port;
drv::split_host_port("stanford.edu:80", host, port);
LuaAssertStrEq(L, host, "stanford.edu");
LuaAssertStrEq(L, port, "80");
return 0;
}