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

@@ -3,9 +3,11 @@
#include "printbuffer.hpp"
#include <cstdio>
struct PrintBufferCore {
// The most recent lines printed.
std::deque<std::string> lines_;
eng::deque<eng::string> lines_;
// Line number of the first line in the buffer. From this, all other
// line numbers can be inferred.
@@ -45,12 +47,12 @@ bool PrintBuffer::never_printed() const {
return (core_->first_line_==0) && (core_->first_unchecked_==0) && (core_->lines_.size()==0);
}
const std::string &PrintBuffer::nth(int n) const {
const eng::string &PrintBuffer::nth(int n) const {
return core_->lines_[n - core_->first_line_];
}
std::string PrintBuffer::debug_string() const {
std::ostringstream oss;
eng::string PrintBuffer::debug_string() const {
eng::ostringstream oss;
oss << core_->first_line_ << "," << core_->first_unchecked_ << ":";
for (int i = 0; i < int(core_->lines_.size()); i++) {
oss << core_->lines_[i] << ";";
@@ -80,7 +82,7 @@ static void add_line(PrintBufferCore *core, const char *text, int len, bool auth
}
}
void PrintBuffer::add_string(const std::string &s, bool auth) {
void PrintBuffer::add_string(const eng::string &s, bool auth) {
const char *text = s.c_str();
int len = s.size();
if (core_ == &shared_core) core_ = new PrintBufferCore;
@@ -118,7 +120,7 @@ void PrintBuffer::serialize(StreamBuffer *sb) const {
sb->write_uint32(core_->first_line_);
sb->write_uint32(core_->first_unchecked_);
sb->write_uint32(core_->lines_.size());
for (const std::string &s : core_->lines_) {
for (const eng::string &s : core_->lines_) {
sb->write_string(s);
}
}
@@ -150,7 +152,7 @@ void PrintBuffer::diff(const PrintBuffer &auth, StreamBuffer *sb) const {
sb->write_int32(auth.first_line());
sb->write_int32(auth.last_line());
for (int i = core_->first_unchecked_; i < auth.last_line(); i++) {
std::string line;
eng::string line;
if (i >= auth.first_line()) line = auth.nth(i);
sb->write_string(line);
}
@@ -174,7 +176,7 @@ void PrintBuffer::patch(StreamBuffer *sb, DebugCollector *dbc) {
}
}
bool PrintChanneler::channel(const PrintBuffer *printbuffer, std::ostream &ostream) {
bool PrintChanneler::channel(const PrintBuffer *printbuffer, eng::ostream &ostream) {
if (printbuffer == nullptr) return false;
if (printbuffer->first_line() > line_) {
line_ = printbuffer->first_line();
@@ -187,7 +189,9 @@ bool PrintChanneler::channel(const PrintBuffer *printbuffer, std::ostream &ostre
}
Invocation PrintChanneler::invocation(int64_t actor_id) {
return Invocation(Invocation::KIND_FLUSH_PRINTS, actor_id, actor_id, std::to_string(line_), InvocationData());
char buf[80];
sprintf(buf, "%ld", line_);
return Invocation(Invocation::KIND_FLUSH_PRINTS, actor_id, actor_id, buf, InvocationData());
}
LuaDefine(unittests_printbuffer, "", "some unit tests") {