OpenVAS Libraries  9.0.3
array.c
Go to the documentation of this file.
1 /* openvas-libraries/base
2  * $Id$
3  * Description: Array utilities.
4  *
5  * Authors:
6  * Matthew Mundell <matthew.mundell@greenbone.net>
7  *
8  * Copyright:
9  * Copyright (C) 2009,2010 Greenbone Networks GmbH
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24  */
25 
31 #include "array.h"
32 
38 GPtrArray *
40 {
41  return g_ptr_array_new ();
42 }
43 
49 void
50 array_reset (array_t ** array)
51 {
52  array_free (*array);
53  *array = make_array ();
54 }
55 
63 void
64 array_free (GPtrArray * array)
65 {
66  if (array)
67  {
68  guint index = array->len;
69  while (index--)
70  g_free (g_ptr_array_index (array, index));
71  g_ptr_array_free (array, TRUE);
72  }
73 }
74 
81 void
82 array_add (array_t * array, gpointer pointer)
83 {
84  if (array)
85  g_ptr_array_add (array, pointer);
86 }
87 
91 void
93 {
94  if (array)
95  g_ptr_array_add (array, NULL);
96 }
void array_reset(array_t **array)
Reset an array.
Definition: array.c:50
void array_free(GPtrArray *array)
Free global array value.
Definition: array.c:64
GPtrArray array_t
Definition: array.h:31
void array_terminate(array_t *array)
Terminate an array.
Definition: array.c:92
void array_add(array_t *array, gpointer pointer)
Push a generic pointer onto an array.
Definition: array.c:82
GPtrArray * make_array()
Make a global array.
Definition: array.c:39