Merge branch '2319-memdup-deprecation' into 'master'

gstrfuncs: Deprecate g_memdup() in favour of g_memdup2()

Closes #2319

See merge request GNOME/glib!1928
This commit is contained in:
Philip Withnall 2021-02-15 12:19:31 +00:00
commit 3dec1b2c00
3 changed files with 10 additions and 3 deletions

View File

@ -380,6 +380,9 @@ g_strdup (const gchar *str)
* *
* Returns: a pointer to the newly-allocated copy of the memory, or %NULL if @mem * Returns: a pointer to the newly-allocated copy of the memory, or %NULL if @mem
* is %NULL. * is %NULL.
* Deprecated: 2.68: Use g_memdup2() instead, as it accepts a #gsize argument
* for @byte_size, avoiding the possibility of overflow in a #gsize #guint
* conversion
*/ */
gpointer gpointer
g_memdup (gconstpointer mem, g_memdup (gconstpointer mem,

View File

@ -253,9 +253,9 @@ GLIB_AVAILABLE_IN_ALL
gchar* g_strescape (const gchar *source, gchar* g_strescape (const gchar *source,
const gchar *exceptions) G_GNUC_MALLOC; const gchar *exceptions) G_GNUC_MALLOC;
GLIB_AVAILABLE_IN_ALL GLIB_DEPRECATED_IN_2_68_FOR (g_memdup2)
gpointer g_memdup (gconstpointer mem, gpointer g_memdup (gconstpointer mem,
guint byte_size) G_GNUC_ALLOC_SIZE(2); guint byte_size) G_GNUC_ALLOC_SIZE(2);
GLIB_AVAILABLE_IN_2_68 GLIB_AVAILABLE_IN_2_68
gpointer g_memdup2 (gconstpointer mem, gpointer g_memdup2 (gconstpointer mem,

View File

@ -205,6 +205,8 @@ test_is_to_digit (void)
static void static void
test_memdup (void) test_memdup (void)
{ {
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gchar *str_dup = NULL; gchar *str_dup = NULL;
const gchar *str = "The quick brown fox jumps over the lazy dog"; const gchar *str = "The quick brown fox jumps over the lazy dog";
@ -219,6 +221,8 @@ test_memdup (void)
g_assert_cmpstr (str, ==, str_dup); g_assert_cmpstr (str, ==, str_dup);
g_free (str_dup); g_free (str_dup);
G_GNUC_END_IGNORE_DEPRECATIONS
} }
/* Testing g_memdup2() function with various positive and negative cases */ /* Testing g_memdup2() function with various positive and negative cases */