80 lines
2.5 KiB
Diff
80 lines
2.5 KiB
Diff
|
From 976fe48829d9dcee11ca33d9fcfdf013f3ad524e Mon Sep 17 00:00:00 2001
|
||
|
Message-Id: <976fe48829d9dcee11ca33d9fcfdf013f3ad524e@dist-git>
|
||
|
From: Peter Krempa <pkrempa@redhat.com>
|
||
|
Date: Tue, 4 Feb 2020 15:07:59 +0100
|
||
|
Subject: [PATCH] util: hash: Use g_new0 for allocating hash internals
|
||
|
MIME-Version: 1.0
|
||
|
Content-Type: text/plain; charset=UTF-8
|
||
|
Content-Transfer-Encoding: 8bit
|
||
|
|
||
|
Use the glib helpers and remove the mention of returning NULL on failure
|
||
|
of virHashNew, virHashCreate and virHashCreateFull.
|
||
|
|
||
|
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
|
||
|
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
|
||
|
(cherry picked from commit 50f7483a0d69906e90849f7f0a30f3f535021852)
|
||
|
|
||
|
https://bugzilla.redhat.com/show_bug.cgi?id=1793263
|
||
|
Message-Id: <c80f6e73321ef7a1d5db60fa56fcadaac63c199b.1580824112.git.pkrempa@redhat.com>
|
||
|
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
||
|
---
|
||
|
src/util/virhash.c | 14 +++++---------
|
||
|
1 file changed, 5 insertions(+), 9 deletions(-)
|
||
|
|
||
|
diff --git a/src/util/virhash.c b/src/util/virhash.c
|
||
|
index edf11e8b7a..d5c5e017a1 100644
|
||
|
--- a/src/util/virhash.c
|
||
|
+++ b/src/util/virhash.c
|
||
|
@@ -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)
|
||
|
{
|
||
|
--
|
||
|
2.25.0
|
||
|
|