vsh-table: Refactor 'vshTableNew'

Use automatic memory freeing to remove 'error' label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa committed 2026-04-24 11:29:01 +02:00
1 parent 37423a24b0
commit c617aa3fbb
1 file changed
+4 -8
+4 -8
View File
@@ -123,8 +123,8 @@ vshTableRowNew(const char *arg, va_list ap)
vshTable *
vshTableNew(const char *arg, ...)
{
vshTable *table = NULL;
vshTableRow *header = NULL;
g_autoptr(vshTable) table = NULL;
g_autoptr(vshTableRow) header = NULL;
va_list ap;
table = g_new0(vshTable, 1);
@@ -134,15 +134,11 @@ vshTableNew(const char *arg, ...)
va_end(ap);
if (!header)
goto error;
return NULL;
VIR_APPEND_ELEMENT(table->rows, table->nrows, header);
return table;
error:
vshTableRowFree(header);
vshTableFree(table);
return NULL;
return g_steal_pointer(&table);
}