Coverage Report

Created: 2026-07-16 07:10

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/fwupd/libfwupdplugin/fu-ptr-array.c
Line
Count
Source
1
/*
2
 * Copyright 2026 Richard Hughes <richard@hughsie.com>
3
 *
4
 * SPDX-License-Identifier: LGPL-2.1-or-later
5
 */
6
7
0
#define G_LOG_DOMAIN "FuCommon"
8
9
#include "config.h"
10
11
#include "fu-ptr-array.h"
12
13
/**
14
 * fu_ptr_array_copy:
15
 * @array: (element-type void): a #GPtrArray
16
 * @func: (scope call): a copy function
17
 * @free_func: (nullable): a free function for the new array
18
 *
19
 * Deep copies a #GPtrArray using @func to copy each element. The new array uses @free_func
20
 * as the element free function.
21
 *
22
 * Returns: (transfer full) (element-type void): a new #GPtrArray
23
 *
24
 * Since: 2.0.8
25
 **/
26
GPtrArray *
27
fu_ptr_array_copy(GPtrArray *array, GCopyFunc func, GDestroyNotify free_func)
28
0
{
29
0
  GPtrArray *array_new;
30
31
0
  g_return_val_if_fail(array != NULL, NULL);
32
0
  g_return_val_if_fail(func != NULL, NULL);
33
34
0
  array_new = g_ptr_array_new_with_free_func(free_func);
35
0
  for (guint i = 0; i < array->len; i++)
36
0
    g_ptr_array_add(array_new, func(g_ptr_array_index(array, i), NULL));
37
0
  return array_new;
38
0
}