More work on moving engine into dlmalloc heap

This commit is contained in:
2022-02-25 19:57:23 -05:00
parent 08f6aa2092
commit ff932dba10
52 changed files with 351 additions and 484 deletions

View File

@@ -6,10 +6,6 @@
#include "drivenengine.hpp"
#include "dummycert.hpp"
#include "util.hpp"
#include "textgame.hpp"
#include "lpxclient.hpp"
#include "lpxserver.hpp"
#include "eng-tests.hpp"
#include "source.hpp"
#include <iostream>
@@ -43,7 +39,7 @@ const int INVALID_SOCKET = -1;
struct termios orig_termios;
static drv::string strerror_str(int err) {
static std::string strerror_str(int err) {
char errbuf[256];
return strerror_r(errno, errbuf, 256);
}
@@ -73,7 +69,7 @@ static void enable_tty_raw() {
assert(status >= 0);
}
static SOCKET open_connection(std::string_view target, drv::string &err) {
static SOCKET open_connection(std::string_view target, std::string &err) {
struct addrinfo *addrs = nullptr;
struct addrinfo *goodaddr = nullptr;
struct addrinfo hints;
@@ -86,7 +82,7 @@ static SOCKET open_connection(std::string_view target, drv::string &err) {
hints.ai_flags = AI_NUMERICSERV;
err.clear();
drv::string host, port;
std::string host, port;
drv::split_host_port(target, host, port);
int status = getaddrinfo(host.c_str(), port.c_str(), &hints, &addrs);
if (status != 0) {
@@ -119,7 +115,7 @@ error_general:
return INVALID_SOCKET;
}
static SOCKET listen_on_port(int port, drv::string &err) {
static SOCKET listen_on_port(int port, std::string &err) {
int status, enable;
err.clear();
@@ -150,7 +146,7 @@ error_errno:
return INVALID_SOCKET;
}
static SOCKET accept_on_socket(SOCKET listen_socket, drv::string &err) {
static SOCKET accept_on_socket(SOCKET listen_socket, std::string &err) {
err.clear();
SOCKET chsock = accept(listen_socket, nullptr, nullptr);
if (chsock >= 0) {
@@ -170,7 +166,7 @@ static SOCKET accept_on_socket(SOCKET listen_socket, drv::string &err) {
// zero: would block
// negative: channel closed, possibly cleanly or possibly with error
//
static int socket_send(SOCKET socket, const char *bytes, int nbytes, drv::string &err) {
static int socket_send(SOCKET socket, const char *bytes, int nbytes, std::string &err) {
err.clear();
int wbytes = send(socket, bytes, nbytes, 0);
if (wbytes < 0) {
@@ -185,7 +181,7 @@ static int socket_send(SOCKET socket, const char *bytes, int nbytes, drv::string
}
}
static int socket_recv(SOCKET socket, char *bytes, int nbytes, drv::string &err) {
static int socket_recv(SOCKET socket, char *bytes, int nbytes, std::string &err) {
err.clear();
int nrecv = recv(socket, bytes, nbytes, 0);
if (nrecv < 0) {
@@ -206,7 +202,7 @@ static int socket_close(SOCKET socket) {
return close(socket);
}
static int socket_poll(struct pollfd *pollvec, int pollcount, int mstimeout, drv::string &err) {
static int socket_poll(struct pollfd *pollvec, int pollcount, int mstimeout, std::string &err) {
// socket_poll is implicitly expected to also poll stdin,
// if the OS allows that. Linux does, so we add stdin to the
// poll vector. The poll vector is required to have at
@@ -272,7 +268,7 @@ int main(int argc, char **argv)
allocate_buffers();
enable_tty_raw();
OPENSSL_init_ssl(0, NULL);
initialize_engine();
SourceDB::register_lua_builtins();
driver_drive(argc, argv);
}