[gtk/popup-shadow-width] tests: Move from g_memdup() to g_memdup2()
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/popup-shadow-width] tests: Move from g_memdup() to g_memdup2()
- Date: Sat, 13 Feb 2021 20:47:16 +0000 (UTC)
commit 7a6f0de7be55ad20ac1ec0bd1dd37839dccf03d4
Author: Emmanuele Bassi <ebassi gnome org>
Date: Thu Feb 4 19:26:58 2021 +0000
tests: Move from g_memdup() to g_memdup2()
The g_memdup() function is replaced by a safer version in newer versions
of GLib.
testsuite/gtk/timsort.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/testsuite/gtk/timsort.c b/testsuite/gtk/timsort.c
index fa524ca162..f7930259f7 100644
--- a/testsuite/gtk/timsort.c
+++ b/testsuite/gtk/timsort.c
@@ -21,6 +21,10 @@
#include "gtk/timsort/gtktimsortprivate.h"
+#if !GLIB_CHECK_VERSION (2, 67, 3)
+# define g_memdup2(mem,size) g_memdup((mem), (size))
+#endif
+
#define assert_sort_equal(a, b, size, n) \
g_assert_cmpmem (a, sizeof (size) * n, b, sizeof (size) * n)
@@ -70,7 +74,9 @@ run_comparison (gpointer a,
gint64 start, mid, end;
gpointer b;
- b = g_memdup (a, element_size * n);
+ g_assert (n <= G_MAXSIZE / element_size);
+
+ b = g_memdup2 (a, element_size * n);
start = g_get_monotonic_time ();
gtk_tim_sort (a, n, element_size, compare_func, data);
@@ -209,7 +215,7 @@ test_steps (void)
a = g_new (int, n);
for (i = 0; i < n; i++)
a[i] = g_test_rand_int ();
- b = g_memdup (a, sizeof (int) * n);
+ b = g_memdup2 (a, sizeof (int) * n);
gtk_tim_sort_init (&sort, a, n, sizeof (int), compare_int, NULL);
gtk_tim_sort_set_max_merge_size (&sort, g_test_rand_int_range (512, 2048));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]