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