Greenbone Vulnerability Management Libraries: base/array.c Source File

Greenbone Vulnerability Management Libraries 23.1.1

array.c
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2009-2023 Greenbone AG
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later
4 */
5
10
11#include "array.h"
12
13#undef G_LOG_DOMAIN
17#define G_LOG_DOMAIN "libgvm base"
18
24GPtrArray *
25make_array (void)
26{
27 return g_ptr_array_new ();
28}
29
35void
36array_reset (array_t **array)
37{
38 array_free (*array);
39 *array = make_array ();
40}
41
49void
50array_free (GPtrArray *array)
51{
52 if (array)
53 {
54 guint index = array->len;
55 while (index--)
56 g_free (g_ptr_array_index (array, index));
57 g_ptr_array_free (array, TRUE);
58 }
59}
60
67void
68array_add (array_t *array, gpointer pointer)
69{
70 if (array)
71 g_ptr_array_add (array, pointer);
72}
73
79void
80array_terminate (array_t *array)
81{
82 if (array)
83 g_ptr_array_add (array, NULL);
84}
array_terminate
void array_terminate(array_t *array)
Terminate an array.
Definition array.c:80
make_array
GPtrArray * make_array(void)
Make a global array.
Definition array.c:25
array_add
void array_add(array_t *array, gpointer pointer)
Push a generic pointer onto an array.
Definition array.c:68
array_reset
void array_reset(array_t **array)
Reset an array.
Definition array.c:36
array_free
void array_free(GPtrArray *array)
Free global array value.
Definition array.c:50
array.h
Array utilities.
array_t
GPtrArray array_t
Definition array.h:16