提交 3f8b040d 编写于 作者: M Michal Privoznik

src/phyp: Utilize more of VIR_(APPEND|INSERT|DELETE)_ELEMENT

Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
上级 d7d06cc1
......@@ -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;
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册