Migrated engine to using dlmalloc through eng::

This commit is contained in:
2022-02-24 02:17:41 -05:00
parent acc00289fb
commit f467944095
61 changed files with 631 additions and 590 deletions

View File

@@ -7,14 +7,14 @@
#include "drivenengine.hpp"
static std::vector<std::pair<std::string, DrivenEngineMaker>> makers;
static eng::vector<eng::pair<eng::string, DrivenEngineMaker>> makers;
void DrivenEngine::register_maker(const char *kind, DrivenEngineMaker maker) {
std::string skind(kind);
eng::string skind(kind);
makers.push_back(std::make_pair(skind, maker));
}
void DrivenEngine::print_usage(std::ostream &strm, const char *progname) {
void DrivenEngine::print_usage(eng::ostream &strm, const char *progname) {
strm << "Usage: " << progname << " <mode>" << std::endl;
for (const auto &mpair : makers) {
strm << " Mode can be: " << mpair.first << std::endl;
@@ -30,7 +30,7 @@ UniqueDrivenEngine DrivenEngine::make(const char *kind) {
return nullptr;
}
Channel::Channel(DrivenEngine *de, int chid, int port, const std::string &target, bool stop) {
Channel::Channel(DrivenEngine *de, int chid, int port, const eng::string &target, bool stop) {
chid_ = chid;
port_ = port;
closed_ = false;
@@ -73,14 +73,14 @@ void Channel::echo_command() {
}
// Echo the new part.
std::string newpart = desired_command_.substr(current_command_.size());
eng::string newpart = desired_command_.substr(current_command_.size());
if (newpart != "") {
sb_drvout_->write_bytes(newpart);
current_command_ = desired_command_;
}
}
void Channel::set_prompt(const std::string &p) {
void Channel::set_prompt(const eng::string &p) {
desired_prompt_ = p;
}
@@ -92,7 +92,7 @@ void Channel::feed_readline(int nbytes, const char *bytes) {
// Otherwise, crlf produces two newlines.
} else if ((c == '\r') || (c == '\n')) {
echo_command();
sb_drvout_->write_bytes(std::string(" \n"));
sb_drvout_->write_bytes(eng::string(" \n"));
sb_in_->write_bytes(desired_command_);
sb_in_->write_uint8('\n');
desired_command_ = "";
@@ -157,7 +157,7 @@ double DrivenEngine::get_clock() {
return clock_;
}
SharedChannel DrivenEngine::new_outgoing_channel(const std::string &target) {
SharedChannel DrivenEngine::new_outgoing_channel(const eng::string &target) {
int chid = find_unused_chid();
new_outgoing_.push_back(chid);
SharedChannel result = std::make_shared<Channel>(this, chid, 0, target, stop_driver_);
@@ -196,11 +196,11 @@ void DrivenEngine::stop_driver() {
}
}
const std::vector<int> &DrivenEngine::drv_get_listen_ports() const {
const eng::vector<int> &DrivenEngine::drv_get_listen_ports() const {
return listen_ports_;
}
const std::vector<int> &DrivenEngine::drv_get_new_outgoing() const {
const eng::vector<int> &DrivenEngine::drv_get_new_outgoing() const {
return new_outgoing_;
}
@@ -208,7 +208,7 @@ void DrivenEngine::drv_clear_new_outgoing() {
new_outgoing_.clear();
}
const std::string &DrivenEngine::drv_get_target(int chid) const {
const eng::string &DrivenEngine::drv_get_target(int chid) const {
return get_chid(chid)->target_;
}
@@ -241,7 +241,7 @@ void DrivenEngine::drv_recv_incoming(int chid, int nbytes, const char *bytes) {
}
}
void DrivenEngine::drv_notify_close(int chid, std::string_view err) {
void DrivenEngine::drv_notify_close(int chid, eng::string_view err) {
Channel *ch = get_chid(chid);
ch->closed_ = true;
ch->error_ = err;
@@ -260,11 +260,11 @@ void DrivenEngine::drv_clear_lua_source() {
rescan_lua_source_ = false;
}
void DrivenEngine::drv_add_lua_source(std::string_view fn, std::string_view data) {
void DrivenEngine::drv_add_lua_source(eng::string_view fn, eng::string_view data) {
if (lua_source_ == nullptr) {
lua_source_.reset(new util::LuaSourceVec);
}
lua_source_->emplace_back(std::string(fn), std::string(data));
lua_source_->emplace_back(eng::string(fn), eng::string(data));
}
void DrivenEngine::drv_invoke_event_init(int argc, char *argv[]) {