cli: return typed PrintDataCol array from _output_selection_parse()
It makes debugging and understanding the code slightly simpler, if we have a pointer of correct type, instead of returning a GArray. We don't need the GArray at this point anymore.
This commit is contained in:
@@ -773,7 +773,8 @@ _output_selection_complete (GArray *cols)
|
|||||||
static gboolean
|
static gboolean
|
||||||
_output_selection_parse (const NMMetaAbstractInfo *const*fields,
|
_output_selection_parse (const NMMetaAbstractInfo *const*fields,
|
||||||
const char *fields_str,
|
const char *fields_str,
|
||||||
GArray **out_cols,
|
PrintDataCol **out_cols_data,
|
||||||
|
guint *out_cols_len,
|
||||||
GPtrArray **out_gfree_keeper,
|
GPtrArray **out_gfree_keeper,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
@@ -807,7 +808,8 @@ _output_selection_parse (const NMMetaAbstractInfo *const*fields,
|
|||||||
|
|
||||||
_output_selection_complete (cols);
|
_output_selection_complete (cols);
|
||||||
|
|
||||||
*out_cols = g_steal_pointer (&cols);
|
*out_cols_len = cols->len;
|
||||||
|
*out_cols_data = (PrintDataCol *) g_array_free (g_steal_pointer (&cols), FALSE);
|
||||||
*out_gfree_keeper = g_steal_pointer (&gfree_keeper);
|
*out_gfree_keeper = g_steal_pointer (&gfree_keeper);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -1374,20 +1376,24 @@ nmc_print (const NmcConfig *nmc_config,
|
|||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gs_unref_ptrarray GPtrArray *gfree_keeper = NULL;
|
gs_unref_ptrarray GPtrArray *gfree_keeper = NULL;
|
||||||
gs_unref_array GArray *cols = NULL;
|
gs_free PrintDataCol *cols_data = NULL;
|
||||||
|
guint cols_len;
|
||||||
gs_unref_array GArray *header_row = NULL;
|
gs_unref_array GArray *header_row = NULL;
|
||||||
gs_unref_array GArray *cells = NULL;
|
gs_unref_array GArray *cells = NULL;
|
||||||
|
|
||||||
if (!_output_selection_parse (fields, fields_str,
|
if (!_output_selection_parse (fields,
|
||||||
&cols, &gfree_keeper,
|
fields_str,
|
||||||
|
&cols_data,
|
||||||
|
&cols_len,
|
||||||
|
&gfree_keeper,
|
||||||
error))
|
error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
_print_fill (nmc_config,
|
_print_fill (nmc_config,
|
||||||
targets,
|
targets,
|
||||||
targets_data,
|
targets_data,
|
||||||
&g_array_index (cols, PrintDataCol, 0),
|
cols_data,
|
||||||
cols->len,
|
cols_len,
|
||||||
&header_row,
|
&header_row,
|
||||||
&cells);
|
&cells);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user