mirror of
https://github.com/libvirt/libvirt.git
synced 2026-10-02 12:20:06 -05:00
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:
1 parent
37423a24b0
commit
c617aa3fbb
1 file changed
+4
-8
+4
-8
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user