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