[glib: 5/8] tests: Use g_ptr_array_set_free_func() rather than manual free()
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 5/8] tests: Use g_ptr_array_set_free_func() rather than manual free()
- Date: Fri, 26 Jul 2019 08:59:54 +0000 (UTC)
commit bc0fcddc1892eeda2e06ddde65379f58d0fb091d
Author: Philip Withnall <withnall endlessm com>
Date: Tue Jul 16 10:17:20 2019 +0100
tests: Use g_ptr_array_set_free_func() rather than manual free()
We don’t need to free array elements manually.
Signed-off-by: Philip Withnall <withnall endlessm com>
glib/tests/array-test.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
---
diff --git a/glib/tests/array-test.c b/glib/tests/array-test.c
index 906812b01..fd8ceb7e1 100644
--- a/glib/tests/array-test.c
+++ b/glib/tests/array-test.c
@@ -964,6 +964,7 @@ pointer_array_copy (void)
/* Test copy through GCopyFunc */
ptr_array2 = g_ptr_array_copy (ptr_array, ptr_array_copy_func, NULL);
+ g_ptr_array_set_free_func (ptr_array2, g_free);
g_assert_cmpuint (ptr_array2->len, ==, ptr_array->len);
for (i = 0; i < array_size; i++)
@@ -973,9 +974,6 @@ pointer_array_copy (void)
g_assert_cmpuint ((gsize) g_ptr_array_index (ptr_array, i), !=,
(gsize) g_ptr_array_index (ptr_array2, i));
- for (i = 0; i < array_size; i++)
- free(ptr_array2->pdata[i]);
-
g_ptr_array_free (ptr_array2, TRUE);
/* Final cleanup */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]