gboxed: Use new g_string_copy() as boxed copy for GString

Rather than reinventing it ourselves. The old version in `gboxed.c`
could lose the second half of very long strings, as it truncated the
`size_t` string length to the `ssize_t` accepted by
`g_string_new_len()`.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3405
This commit is contained in:
Philip Withnall 2025-04-11 14:57:29 +01:00
parent 3048266aa3
commit b9d2719222
No known key found for this signature in database
GPG Key ID: C5C42CFB268637CA

View File

@ -96,12 +96,6 @@ _g_boxed_type_init (void)
g_assert (type == G_TYPE_BOXED);
}
static GString *
gstring_copy (GString *src_gstring)
{
return g_string_new_len (src_gstring->str, src_gstring->len);
}
static void
gstring_free (GString *gstring)
{
@ -113,7 +107,7 @@ G_DEFINE_BOXED_TYPE (GValue, g_value, value_copy, value_free)
G_DEFINE_BOXED_TYPE (GValueArray, g_value_array, g_value_array_copy, g_value_array_free)
G_DEFINE_BOXED_TYPE (GDate, g_date, g_date_copy, g_date_free)
/* the naming is a bit odd, but GString is obviously not G_TYPE_STRING */
G_DEFINE_BOXED_TYPE (GString, g_gstring, gstring_copy, gstring_free)
G_DEFINE_BOXED_TYPE (GString, g_gstring, g_string_copy, gstring_free)
G_DEFINE_BOXED_TYPE (GHashTable, g_hash_table, g_hash_table_ref, g_hash_table_unref)
G_DEFINE_BOXED_TYPE (GArray, g_array, g_array_ref, g_array_unref)
G_DEFINE_BOXED_TYPE (GPtrArray, g_ptr_array,g_ptr_array_ref, g_ptr_array_unref)