Migrated engine to using dlmalloc through eng::
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
#include "textgame.hpp"
|
||||
#include "lpxclient.hpp"
|
||||
#include "lpxserver.hpp"
|
||||
#include "drivertests.hpp"
|
||||
#include "eng-tests.hpp"
|
||||
#include "source.hpp"
|
||||
|
||||
#include <iostream>
|
||||
@@ -35,8 +35,8 @@
|
||||
#define CHBUF_SIZE (256*1024)
|
||||
#define POLLVEC_SIZE (DrivenEngine::MAX_CHAN+1)
|
||||
|
||||
static std::unique_ptr<char[]> chbuf;
|
||||
static std::unique_ptr<struct pollfd[]> pollvec;
|
||||
static drv::unique_ptr<char[]> chbuf;
|
||||
static drv::unique_ptr<struct pollfd[]> pollvec;
|
||||
|
||||
static void set_nonblocking(SOCKET sock) {
|
||||
u_long mode = 1; // 1 to enable non-blocking socket
|
||||
@@ -44,8 +44,8 @@ static void set_nonblocking(SOCKET sock) {
|
||||
assert(status == 0);
|
||||
}
|
||||
|
||||
static std::string winsock_error_string(int errcode) {
|
||||
std::ostringstream oss;
|
||||
static drv::string winsock_error_string(int errcode) {
|
||||
drv::ostringstream oss;
|
||||
oss << "error " << errcode;
|
||||
return oss.str();
|
||||
}
|
||||
@@ -55,15 +55,15 @@ static PADDRINFOA find_good_addr(PADDRINFOA addrinfo) {
|
||||
if (addr->ai_family == AF_INET) {
|
||||
return addr;
|
||||
}
|
||||
}std::string
|
||||
}drv::string
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static SOCKET open_connection(std::string_view target, std::string &err) {
|
||||
static SOCKET open_connection(drv::string_view target, drv::string &err) {
|
||||
PADDRINFOA addrs = nullptr;
|
||||
PADDRINFOA goodaddr = nullptr;
|
||||
SOCKET sock = INVALID_SOCKET;
|
||||
std::string_view host, port;
|
||||
drv::string_view host, port;
|
||||
|
||||
err.clear();
|
||||
util::split_host_port(target, host, port);
|
||||
@@ -107,7 +107,7 @@ error:
|
||||
return SOCKET_ERROR;
|
||||
}
|
||||
|
||||
SOCKET listen_on_port(int port, std::string &err) {
|
||||
SOCKET listen_on_port(int port, drv::string &err) {
|
||||
int status;
|
||||
err.clear();
|
||||
SOCKET sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||
@@ -140,7 +140,7 @@ error:
|
||||
return SOCKET_ERROR;
|
||||
}
|
||||
|
||||
static SOCKET accept_on_socket(SOCKET listen_socket, std::string &err) {
|
||||
static SOCKET accept_on_socket(SOCKET listen_socket, drv::string &err) {
|
||||
SOCKET chsock = accept(listen_socket, nullptr, nullptr);
|
||||
if (chsock != INVALID_SOCKET) {
|
||||
set_nonblocking(chsock);
|
||||
@@ -156,7 +156,7 @@ static SOCKET accept_on_socket(SOCKET listen_socket, std::string &err) {
|
||||
}
|
||||
}
|
||||
|
||||
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 == SOCKET_ERROR) {
|
||||
@@ -173,7 +173,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) {
|
||||
@@ -195,7 +195,7 @@ static int socket_close(SOCKET socket) {
|
||||
return closesocket(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) {
|
||||
int status = WSAPoll(pollvec, pollcount, mstimeout);
|
||||
if (status < 0) {
|
||||
err = winsock_error_string(WSAGetLastError());
|
||||
|
||||
Reference in New Issue
Block a user