[gtk/ebassi/memdup2: 11/11] tests: Move from g_memdup() to g_memdup2()




commit 09c838abc1884ac8c7ac40e302ce2809ca8a57d9
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 | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/testsuite/gtk/timsort.c b/testsuite/gtk/timsort.c
index fa524ca162..9cfcf2468c 100644
--- a/testsuite/gtk/timsort.c
+++ b/testsuite/gtk/timsort.c
@@ -70,7 +70,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 +211,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]