提交 50f7483a 编写于 作者: P Peter Krempa

util: hash: Use g_new0 for allocating hash internals

Use the glib helpers and remove the mention of returning NULL on failure
of virHashNew, virHashCreate and virHashCreateFull.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
上级 b918bfba
......@@ -138,7 +138,7 @@ virHashComputeKey(const virHashTable *table, const void *name)
*
* Create a new virHashTablePtr.
*
* Returns the newly created object, or NULL if an error occurred.
* Returns the newly created object.
*/
virHashTablePtr virHashCreateFull(ssize_t size,
virHashDataFree dataFree,
......@@ -153,8 +153,7 @@ virHashTablePtr virHashCreateFull(ssize_t size,
if (size <= 0)
size = 256;
if (VIR_ALLOC(table) < 0)
return NULL;
table = g_new0(virHashTable, 1);
table->seed = virRandomBits(32);
table->size = size;
......@@ -166,10 +165,7 @@ virHashTablePtr virHashCreateFull(ssize_t size,
table->keyPrint = keyPrint;
table->keyFree = keyFree;
if (VIR_ALLOC_N(table->table, size) < 0) {
VIR_FREE(table);
return NULL;
}
table->table = g_new0(virHashEntryPtr, table->size);
return table;
}
......@@ -181,7 +177,7 @@ virHashTablePtr virHashCreateFull(ssize_t size,
*
* Create a new virHashTablePtr.
*
* Returns the newly created object, or NULL if an error occurred.
* Returns the newly created object.
*/
virHashTablePtr
virHashNew(virHashDataFree dataFree)
......@@ -203,7 +199,7 @@ virHashNew(virHashDataFree dataFree)
*
* Create a new virHashTablePtr.
*
* Returns the newly created object, or NULL if an error occurred.
* Returns the newly created object.
*/
virHashTablePtr virHashCreate(ssize_t size, virHashDataFree dataFree)
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册