replace str->str & g_string_free with g_string_free_and_steal

solving unused warning in GLib 2.76
This commit is contained in:
Ailin Nemui 2025-07-22 11:40:04 +02:00
commit 8eee36d1ea
20 changed files with 73 additions and 78 deletions

View file

@ -19,6 +19,7 @@
*/
#include "module.h"
#include <irssi/src/core/misc.h>
#include <irssi/src/core/levels.h>
/* the order of these levels must match the bits in levels.h */
@ -169,8 +170,7 @@ char *bits2level(int bits)
if (str->len > 0)
g_string_truncate(str, str->len-1);
ret = str->str;
g_string_free(str, FALSE);
ret = g_string_free_and_steal(str);
return ret;
}

View file

@ -135,6 +135,15 @@ GDateTime *g_date_time_new_from_iso8601(const gchar *iso_date, GTimeZone *defaul
}
#endif
#if GLIB_CHECK_VERSION(2, 76, 0)
/* nothing */
#else
gchar *g_string_free_and_steal(GString *string)
{
return g_string_free(string, FALSE);
}
#endif
int find_substr(const char *list, const char *item)
{
const char *ptr;
@ -261,8 +270,7 @@ char *gslistptr_to_string(GSList *list, int offset, const char *delimiter)
list = list->next;
}
ret = str->str;
g_string_free(str, FALSE);
ret = g_string_free_and_steal(str);
return ret;
}
@ -280,8 +288,7 @@ char *i_slist_to_string(GSList *list, const char *delimiter)
list = list->next;
}
ret = str->str;
g_string_free(str, FALSE);
ret = g_string_free_and_steal(str);
return ret;
}

View file

@ -26,6 +26,12 @@ long get_timeval_diff(const GTimeVal *tv1, const GTimeVal *tv2) G_GNUC_DEPRECATE
GDateTime *g_date_time_new_from_iso8601(const gchar *iso_date, GTimeZone *default_tz);
#endif
#if GLIB_CHECK_VERSION(2, 76, 0)
/* nothing */
#else
gchar *g_string_free_and_steal(GString *string);
#endif
GSList *i_slist_find_string(GSList *list, const char *key);
GSList *i_slist_find_icase_string(GSList *list, const char *key);
GList *i_list_find_string(GList *list, const char *key);

View file

@ -134,8 +134,7 @@ static char *server_create_tag(SERVER_CONNECT_REC *conn)
}
g_free(tag);
tag = str->str;
g_string_free(str, FALSE);
tag = g_string_free(str, FALSE);
return tag;
}

View file

@ -88,8 +88,7 @@ static char *get_argument(char **cmd, char **arglist)
}
if (str->len > 0) g_string_truncate(str, str->len-1);
ret = str->str;
g_string_free(str, FALSE);
ret = g_string_free_and_steal(str);
return ret;
}
@ -412,8 +411,7 @@ char *get_alignment(const char *text, int align, int flags, char pad)
}
}
ret = str->str;
g_string_free(str, FALSE);
ret = g_string_free_and_steal(str);
return ret;
}
@ -604,8 +602,7 @@ char *parse_special_string(const char *cmd, SERVER_REC *server, void *item,
}
g_strfreev(arglist);
ret = str->str;
g_string_free(str, FALSE);
ret = g_string_free_and_steal(str);
return ret;
}