mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 07:59:00 +00:00
src/phyp: Utilize more of VIR_(APPEND|INSERT|DELETE)_ELEMENT
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
d7d06cc183
commit
3f8b040d9a
@ -570,19 +570,16 @@ phypUUIDTable_AddLpar(virConnectPtr conn, unsigned char *uuid, int id)
|
||||
{
|
||||
phyp_driverPtr phyp_driver = conn->privateData;
|
||||
uuid_tablePtr uuid_table = phyp_driver->uuid_table;
|
||||
lparPtr item = NULL;
|
||||
|
||||
uuid_table->nlpars++;
|
||||
size_t i = uuid_table->nlpars;
|
||||
i--;
|
||||
|
||||
if (VIR_REALLOC_N(uuid_table->lpars, uuid_table->nlpars) < 0)
|
||||
if (VIR_ALLOC(item) < 0)
|
||||
goto err;
|
||||
|
||||
if (VIR_ALLOC(uuid_table->lpars[i]) < 0)
|
||||
goto err;
|
||||
item->id = id;
|
||||
memcpy(item->uuid, uuid, VIR_UUID_BUFLEN);
|
||||
|
||||
uuid_table->lpars[i]->id = id;
|
||||
memcpy(uuid_table->lpars[i]->uuid, uuid, VIR_UUID_BUFLEN);
|
||||
if (VIR_APPEND_ELEMENT_COPY(uuid_table->lpars, uuid_table->nlpars, item) < 0)
|
||||
goto err;
|
||||
|
||||
if (phypUUIDTable_WriteFile(conn) == -1)
|
||||
goto err;
|
||||
@ -593,6 +590,7 @@ phypUUIDTable_AddLpar(virConnectPtr conn, unsigned char *uuid, int id)
|
||||
return 0;
|
||||
|
||||
err:
|
||||
VIR_FREE(item);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ struct _lpar {
|
||||
typedef struct _uuid_table uuid_table_t;
|
||||
typedef uuid_table_t *uuid_tablePtr;
|
||||
struct _uuid_table {
|
||||
int nlpars;
|
||||
size_t nlpars;
|
||||
lparPtr *lpars;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user