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 <stdint.h> to the header.
This commit is contained in:
2026-01-25 23:37:09 -07:00
parent d4134c94b3
commit c8ee118f00
3 changed files with 13 additions and 12 deletions

View File

@@ -18,14 +18,13 @@
#include <string.h>
#include <stdlib.h>
#include <glib.h>
#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;
}
}

View File

@@ -23,7 +23,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <glib.h>
#include <stdint.h>
#ifndef WIN32
#include <unistd.h>
@@ -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 */

View File

@@ -20,6 +20,8 @@
#ifndef ZOITECHAT_NETWORK_H
#define ZOITECHAT_NETWORK_H
#include <stdint.h>
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