|
|
a41c76 |
From 976fe48829d9dcee11ca33d9fcfdf013f3ad524e Mon Sep 17 00:00:00 2001
|
|
|
a41c76 |
Message-Id: <976fe48829d9dcee11ca33d9fcfdf013f3ad524e@dist-git>
|
|
|
a41c76 |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
a41c76 |
Date: Tue, 4 Feb 2020 15:07:59 +0100
|
|
|
a41c76 |
Subject: [PATCH] util: hash: Use g_new0 for allocating hash internals
|
|
|
a41c76 |
MIME-Version: 1.0
|
|
|
a41c76 |
Content-Type: text/plain; charset=UTF-8
|
|
|
a41c76 |
Content-Transfer-Encoding: 8bit
|
|
|
a41c76 |
|
|
|
a41c76 |
Use the glib helpers and remove the mention of returning NULL on failure
|
|
|
a41c76 |
of virHashNew, virHashCreate and virHashCreateFull.
|
|
|
a41c76 |
|
|
|
a41c76 |
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
|
|
|
a41c76 |
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
a41c76 |
(cherry picked from commit 50f7483a0d69906e90849f7f0a30f3f535021852)
|
|
|
a41c76 |
|
|
|
a41c76 |
https://bugzilla.redhat.com/show_bug.cgi?id=1793263
|
|
|
a41c76 |
Message-Id: <c80f6e73321ef7a1d5db60fa56fcadaac63c199b.1580824112.git.pkrempa@redhat.com>
|
|
|
a41c76 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
a41c76 |
---
|
|
|
a41c76 |
src/util/virhash.c | 14 +++++---------
|
|
|
a41c76 |
1 file changed, 5 insertions(+), 9 deletions(-)
|
|
|
a41c76 |
|
|
|
a41c76 |
diff --git a/src/util/virhash.c b/src/util/virhash.c
|
|
|
a41c76 |
index edf11e8b7a..d5c5e017a1 100644
|
|
|
a41c76 |
--- a/src/util/virhash.c
|
|
|
a41c76 |
+++ b/src/util/virhash.c
|
|
|
a41c76 |
@@ -138,7 +138,7 @@ virHashComputeKey(const virHashTable *table, const void *name)
|
|
|
a41c76 |
*
|
|
|
a41c76 |
* Create a new virHashTablePtr.
|
|
|
a41c76 |
*
|
|
|
a41c76 |
- * Returns the newly created object, or NULL if an error occurred.
|
|
|
a41c76 |
+ * Returns the newly created object.
|
|
|
a41c76 |
*/
|
|
|
a41c76 |
virHashTablePtr virHashCreateFull(ssize_t size,
|
|
|
a41c76 |
virHashDataFree dataFree,
|
|
|
a41c76 |
@@ -153,8 +153,7 @@ virHashTablePtr virHashCreateFull(ssize_t size,
|
|
|
a41c76 |
if (size <= 0)
|
|
|
a41c76 |
size = 256;
|
|
|
a41c76 |
|
|
|
a41c76 |
- if (VIR_ALLOC(table) < 0)
|
|
|
a41c76 |
- return NULL;
|
|
|
a41c76 |
+ table = g_new0(virHashTable, 1);
|
|
|
a41c76 |
|
|
|
a41c76 |
table->seed = virRandomBits(32);
|
|
|
a41c76 |
table->size = size;
|
|
|
a41c76 |
@@ -166,10 +165,7 @@ virHashTablePtr virHashCreateFull(ssize_t size,
|
|
|
a41c76 |
table->keyPrint = keyPrint;
|
|
|
a41c76 |
table->keyFree = keyFree;
|
|
|
a41c76 |
|
|
|
a41c76 |
- if (VIR_ALLOC_N(table->table, size) < 0) {
|
|
|
a41c76 |
- VIR_FREE(table);
|
|
|
a41c76 |
- return NULL;
|
|
|
a41c76 |
- }
|
|
|
a41c76 |
+ table->table = g_new0(virHashEntryPtr, table->size);
|
|
|
a41c76 |
|
|
|
a41c76 |
return table;
|
|
|
a41c76 |
}
|
|
|
a41c76 |
@@ -181,7 +177,7 @@ virHashTablePtr virHashCreateFull(ssize_t size,
|
|
|
a41c76 |
*
|
|
|
a41c76 |
* Create a new virHashTablePtr.
|
|
|
a41c76 |
*
|
|
|
a41c76 |
- * Returns the newly created object, or NULL if an error occurred.
|
|
|
a41c76 |
+ * Returns the newly created object.
|
|
|
a41c76 |
*/
|
|
|
a41c76 |
virHashTablePtr
|
|
|
a41c76 |
virHashNew(virHashDataFree dataFree)
|
|
|
a41c76 |
@@ -203,7 +199,7 @@ virHashNew(virHashDataFree dataFree)
|
|
|
a41c76 |
*
|
|
|
a41c76 |
* Create a new virHashTablePtr.
|
|
|
a41c76 |
*
|
|
|
a41c76 |
- * Returns the newly created object, or NULL if an error occurred.
|
|
|
a41c76 |
+ * Returns the newly created object.
|
|
|
a41c76 |
*/
|
|
|
a41c76 |
virHashTablePtr virHashCreate(ssize_t size, virHashDataFree dataFree)
|
|
|
a41c76 |
{
|
|
|
a41c76 |
--
|
|
|
a41c76 |
2.25.0
|
|
|
a41c76 |
|