Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- src/phyp/phyp_driver.c | 16 +++++++--------- src/phyp/phyp_driver.h | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 9adb6b0..e819256 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -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; } diff --git a/src/phyp/phyp_driver.h b/src/phyp/phyp_driver.h index ad05b15..a5e7369 100644 --- a/src/phyp/phyp_driver.h +++ b/src/phyp/phyp_driver.h @@ -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; }; -- 1.9.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list