From c8ee118f00d8a12a64f9792b9d43c8da1720638e Mon Sep 17 00:00:00 2001 From: deepend Date: Sun, 25 Jan 2026 23:37:09 -0700 Subject: [PATCH] Replaced GLib allocation helpers in history management with standard free/strdup to reduce unnecessary GLib coupling. Updated the network helper API to use uint32_t and standard allocation/duplication routines, dropping the GLib include from the implementation and adding to the header. --- src/common/history.c | 7 +++---- src/common/network.c | 14 +++++++------- src/common/network.h | 4 +++- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/common/history.c b/src/common/history.c index 23a8463e..c6529f30 100644 --- a/src/common/history.c +++ b/src/common/history.c @@ -18,14 +18,13 @@ #include #include -#include #include "history.h" void history_add (struct history *his, char *text) { - g_free (his->lines[his->realpos]); - his->lines[his->realpos] = g_strdup (text); + free (his->lines[his->realpos]); + his->lines[his->realpos] = strdup (text); his->realpos++; if (his->realpos == HISTORY_SIZE) his->realpos = 0; @@ -40,7 +39,7 @@ history_free (struct history *his) { if (his->lines[i]) { - g_free (his->lines[i]); + free (his->lines[i]); his->lines[i] = 0; } } diff --git a/src/common/network.c b/src/common/network.c index fcdaf547..52e7ece5 100644 --- a/src/common/network.c +++ b/src/common/network.c @@ -23,7 +23,7 @@ #include #include #include -#include +#include #ifndef WIN32 #include @@ -54,7 +54,7 @@ net_set_socket_options (int sok) } char * -net_ip (guint32 addr) +net_ip (uint32_t addr) { struct in_addr ia; @@ -67,13 +67,13 @@ net_store_destroy (netstore * ns) { if (ns->ip6_hostent) freeaddrinfo (ns->ip6_hostent); - g_free (ns); + free (ns); } netstore * net_store_new (void) { - return g_new0 (netstore, 1); + return calloc (1, sizeof (netstore)); } /* =================== IPV6 ================== */ @@ -121,11 +121,11 @@ net_resolve (netstore * ns, char *hostname, int port, char **real_host) ipstring, sizeof (ipstring), NULL, 0, NI_NUMERICHOST); if (ns->ip6_hostent->ai_canonname) - *real_host = g_strdup (ns->ip6_hostent->ai_canonname); + *real_host = strdup (ns->ip6_hostent->ai_canonname); else - *real_host = g_strdup (hostname); + *real_host = strdup (hostname); - return g_strdup (ipstring); + return strdup (ipstring); } /* the only thing making this interface unclean, this shitty sok4, sok6 business */ diff --git a/src/common/network.h b/src/common/network.h index 7ecfd39a..537f2a84 100644 --- a/src/common/network.h +++ b/src/common/network.h @@ -20,6 +20,8 @@ #ifndef ZOITECHAT_NETWORK_H #define ZOITECHAT_NETWORK_H +#include + typedef struct netstore_ { #ifdef NETWORK_PRIVATE @@ -36,7 +38,7 @@ void net_store_destroy (netstore *ns); int net_connect (netstore *ns, int sok4, int sok6, int *sok_return); char *net_resolve (netstore *ns, char *hostname, int port, char **real_host); void net_bind (netstore *tobindto, int sok4, int sok6); -char *net_ip (guint32 addr); +char *net_ip (uint32_t addr); void net_sockets (int *sok4, int *sok6); #endif