From 672c3963974bef02740dc3d4ac657876583b170d Mon Sep 17 00:00:00 2001
From: Michael Catanzaro <mcatanzaro@gnome.org>
Date: Wed, 31 Mar 2021 10:00:46 -0500
Subject: [PATCH 12/12] Use more g_memdup2
This completes the removal of g_memdup() usage for GLib 2.56.
---
gio/gwin32appinfo.c | 3 ++-
glib/ghash.c | 2 +-
glib/tests/gvariant.c | 9 +++++----
3 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/gio/gwin32appinfo.c b/gio/gwin32appinfo.c
index 499bbb351..749b282dc 100644
--- a/gio/gwin32appinfo.c
+++ b/gio/gwin32appinfo.c
@@ -32,6 +32,7 @@
#include <glib/gstdio.h>
#include "glibintl.h"
#include <gio/gwin32registrykey.h>
+#include "gstrfuncsprivate.h"
#include <windows.h>
@@ -472,7 +473,7 @@ g_wcsdup (const gunichar2 *str, gssize str_size)
str_size = wcslen (str) + 1;
str_size *= sizeof (gunichar2);
}
- return g_memdup (str, str_size);
+ return g_memdup2 (str, str_size);
}
#define URL_ASSOCIATIONS L"HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\"
diff --git a/glib/ghash.c b/glib/ghash.c
index d475e6d64..608d136f4 100644
--- a/glib/ghash.c
+++ b/glib/ghash.c
@@ -968,7 +968,7 @@ g_hash_table_insert_node (GHashTable *hash_table,
* split the table.
*/
if (G_UNLIKELY (hash_table->keys == hash_table->values && hash_table->keys[node_index] != new_value))
- hash_table->values = g_memdup (hash_table->keys, sizeof (gpointer) * hash_table->size);
+ hash_table->values = g_memdup2 (hash_table->keys, sizeof (gpointer) * hash_table->size);
/* Step 3: Actually do the write */
hash_table->values[node_index] = new_value;
diff --git a/glib/tests/gvariant.c b/glib/tests/gvariant.c
index c4a996c1f..5903b69bc 100644
--- a/glib/tests/gvariant.c
+++ b/glib/tests/gvariant.c
@@ -14,6 +14,7 @@
#include "config.h"
#include <glib/gvariant-internal.h>
+#include <glib/gstrfuncsprivate.h>
#include <string.h>
#include <stdlib.h>
#include <glib.h>
@@ -4673,7 +4674,7 @@ test_normal_checking_tuples (void)
GVariant *variant = NULL;
GVariant *normal_variant = NULL;
- aligned_data = g_memdup (data, size); /* guarantee alignment */
+ aligned_data = g_memdup2 (data, size); /* guarantee alignment */
variant = g_variant_new_from_data (G_VARIANT_TYPE_VARIANT, aligned_data, size,
FALSE, NULL, NULL);
g_assert_nonnull (variant);
@@ -4802,7 +4803,7 @@ test_normal_checking_array_offsets (void)
GVariant *variant = NULL;
GVariant *normal_variant = NULL;
- aligned_data = g_memdup (data, size); /* guarantee alignment */
+ aligned_data = g_memdup2 (data, size); /* guarantee alignment */
variant = g_variant_new_from_data (G_VARIANT_TYPE_VARIANT, aligned_data, size,
FALSE, NULL, NULL);
g_assert_nonnull (variant);
@@ -4829,7 +4830,7 @@ test_normal_checking_tuple_offsets (void)
GVariant *variant = NULL;
GVariant *normal_variant = NULL;
- aligned_data = g_memdup (data, size); /* guarantee alignment */
+ aligned_data = g_memdup2 (data, size); /* guarantee alignment */
variant = g_variant_new_from_data (G_VARIANT_TYPE_VARIANT, aligned_data,
size, FALSE, NULL, NULL);
g_assert_nonnull (variant);
@@ -4856,7 +4857,7 @@ test_normal_checking_empty_object_path (void)
GVariant *variant = NULL;
GVariant *normal_variant = NULL;
- aligned_data = g_memdup (data, size); /* guarantee alignment */
+ aligned_data = g_memdup2 (data, size); /* guarantee alignment */
variant = g_variant_new_from_data (G_VARIANT_TYPE_VARIANT, aligned_data, size,
FALSE, NULL, NULL);
g_assert_nonnull (variant);
--
2.31.1