-struct str_array_s
-{
- char **ptr;
- size_t size;
-};
-typedef struct str_array_s str_array_t;
-
-static str_array_t *array_alloc (void) /* {{{ */
-{
- str_array_t *a;
-
- a = malloc (sizeof (*a));
- if (a == NULL)
- return (NULL);
-
- memset (a, 0, sizeof (*a));
- a->ptr = NULL;
- a->size = 0;
-
- return (a);
-} /* }}} str_array_t *array_alloc */
-
-static void array_free (str_array_t *a) /* {{{ */
-{
- if (a == NULL)
- return;
-
- free (a->ptr);
- a->ptr = NULL;
- a->size = 0;
-
- free (a);
-} /* }}} void array_free */
-
-static int array_add (const char *entry, void *user_data) /* {{{ */
-{
- str_array_t *a = user_data;
- char **ptr;
-
- if ((entry == NULL) || (a == NULL))
- return (EINVAL);
-
- ptr = realloc (a->ptr, sizeof (*a->ptr) * (a->size + 1));
- if (ptr == NULL)
- return (ENOMEM);
- a->ptr = ptr;
- ptr = a->ptr + a->size;
-
- *ptr = strdup (entry);
- if (*ptr == NULL)
- return (ENOMEM);
-
- a->size++;
- return (0);
-} /* }}} int array_add */
-
-static int print_graph (const graph_list_t *gl, void *user_data) /* {{{ */
-{
- if (gl == NULL)
- return (EINVAL);
-
- printf ("host = %s; plugin = %s;", gl->host, gl->plugin);
- if (gl->plugin_instance != NULL)
- printf (" plugin_instance = %s;", gl->plugin_instance);
- printf (" type = %s;", gl->type);
- if (gl->type_instance != NULL)
- printf (" type_instance = %s;", gl->type_instance);
- printf ("\n");
-
- return (0);
-} /* }}} int print_graph */