From 314e68098698569d07dfcdd36c164d8522acc2a8 Mon Sep 17 00:00:00 2001 From: Egor Date: Fri, 13 Jun 2025 04:38:21 +0300 Subject: [PATCH] remove allocClient --- src/main.cpp | 4 ++-- src/net.cpp | 8 +------- src/net.h | 1 - 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 49cb835..d579c05 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -141,7 +141,7 @@ static void accept_from_sock(struct listener *listener) #endif } // Add to list of sockets - struct client_data *cl = allocClient(); + client_data *cl = new client_data(); cl->fd = fd; cl->cctx = cctx; cl->type = addr.ss_family == AF_INET6 ? 6 : 4; @@ -291,7 +291,7 @@ int main(int argc, char *argv[]) FILE *f = fopen(getdatafile("init.txt"), "rbe"); if (f) { - struct client_data *fake = allocClient(); + client_data *fake = new client_data(); fake->fd = -1; fake->umode |= UMODE_OPER | UMODE_SECURE; fake->hostname = mystrdup("localhost"); diff --git a/src/net.cpp b/src/net.cpp index 4bd3862..02fd14b 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -6,12 +6,6 @@ #include "irc.h" #include "ircfmt.h" #include "job.h" - -struct client_data *allocClient(void) -{ - return (struct client_data *)calloc(1, sizeof(struct client_data)); -} - void update_poll_reg(struct client_data *cl) { if (cl->fd == -1) @@ -152,7 +146,7 @@ void killConnectionPart2(struct client_data *cl) free(cl->saslusername); free(cl->webircpeername); free(cl->webirchostname); - free(cl); + delete cl; } void recvProc(struct client_data *cl) { diff --git a/src/net.h b/src/net.h index 47330d1..a2c5adc 100644 --- a/src/net.h +++ b/src/net.h @@ -7,7 +7,6 @@ void sendbuf(struct client_data *client); void sendbuf_visible(struct client_data *client); -struct client_data *allocClient(void); void update_poll_reg(struct client_data *cl); void log_client(struct client_data *cl, const char *format, ...); void killConnection(struct client_data *client, int byChoice); -- 2.56.0