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

@@ -9,7 +9,7 @@
#include "textgame.hpp"
#include "lpxclient.hpp"
#include "lpxserver.hpp"
#include "drivertests.hpp"
#include "eng-tests.hpp"
#include "source.hpp"
#include <iostream>
@@ -43,7 +43,7 @@ const int INVALID_SOCKET = -1;
struct termios orig_termios;
static std::string strerror_str(int err) {
static drv::string strerror_str(int err) {
char errbuf[256];
return strerror_r(errno, errbuf, 256);
}
@@ -73,7 +73,7 @@ static void enable_tty_raw() {
assert(status >= 0);
}
static SOCKET open_connection(std::string_view target, std::string &err) {
static SOCKET open_connection(drv::string_view target, drv::string &err) {
struct addrinfo *addrs = nullptr;
struct addrinfo *goodaddr = nullptr;
struct addrinfo hints;
@@ -86,7 +86,7 @@ static SOCKET open_connection(std::string_view target, std::string &err) {
hints.ai_flags = AI_NUMERICSERV;
err.clear();
std::string host, port;
drv::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 +119,7 @@ error_general:
return INVALID_SOCKET;
}
static SOCKET listen_on_port(int port, std::string &err) {
static SOCKET listen_on_port(int port, drv::string &err) {
int status, enable;
err.clear();
@@ -150,7 +150,7 @@ error_errno:
return INVALID_SOCKET;
}
static SOCKET accept_on_socket(SOCKET listen_socket, std::string &err) {
static SOCKET accept_on_socket(SOCKET listen_socket, drv::string &err) {
err.clear();
SOCKET chsock = accept(listen_socket, nullptr, nullptr);
if (chsock >= 0) {
@@ -170,7 +170,7 @@ static SOCKET accept_on_socket(SOCKET listen_socket, std::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, std::string &err) {
static int socket_send(SOCKET socket, const char *bytes, int nbytes, drv::string &err) {
err.clear();
int wbytes = send(socket, bytes, nbytes, 0);
if (wbytes < 0) {
@@ -185,7 +185,7 @@ static int socket_send(SOCKET socket, const char *bytes, int nbytes, std::string
}
}
static int socket_recv(SOCKET socket, char *bytes, int nbytes, std::string &err) {
static int socket_recv(SOCKET socket, char *bytes, int nbytes, drv::string &err) {
err.clear();
int nrecv = recv(socket, bytes, nbytes, 0);
if (nrecv < 0) {
@@ -206,7 +206,7 @@ static int socket_close(SOCKET socket) {
return close(socket);
}
static int socket_poll(struct pollfd *pollvec, int pollcount, int mstimeout, std::string &err) {
static int socket_poll(struct pollfd *pollvec, int pollcount, int mstimeout, drv::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