The only place we call it is in virHashNew. Move the code to virHashNew
and remove virHashCreateFull.
Code wishing to use non-strings as hash table keys will be better off
using glib's GHashTable directly.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/util/virhash.c | 53 +++++++++-------------------------------------
src/util/virhash.h | 7 ------
2 files changed, 10 insertions(+), 50 deletions(-)
diff --git a/src/util/virhash.c b/src/util/virhash.c
index c781e1d5a5..8d56b4bb85 100644
--- a/src/util/virhash.c
+++ b/src/util/virhash.c
@@ -118,43 +118,31 @@ virHashComputeKey(const virHashTable *table, const void *name)
return value % table->size;
}
+
/**
- * virHashCreateFull:
- * @size: the size of the hash table
+ * virHashNew:
* @dataFree: callback to free data
- * @keyCode: callback to compute hash code
- * @keyEqual: callback to compare hash keys
- * @keyCopy: callback to copy hash keys
- * @keyFree: callback to free keys
*
* Create a new virHashTablePtr.
*
* Returns the newly created object.
*/
-virHashTablePtr virHashCreateFull(ssize_t size,
- virHashDataFree dataFree,
- virHashKeyCode keyCode,
- virHashKeyEqual keyEqual,
- virHashKeyCopy keyCopy,
- virHashKeyPrintHuman keyPrint,
- virHashKeyFree keyFree)
+virHashTablePtr
+virHashNew(virHashDataFree dataFree)
{
virHashTablePtr table = NULL;
- if (size <= 0)
- size = 256;
-
table = g_new0(virHashTable, 1);
table->seed = virRandomBits(32);
- table->size = size;
+ table->size = 32;
table->nbElems = 0;
table->dataFree = dataFree;
- table->keyCode = keyCode;
- table->keyEqual = keyEqual;
- table->keyCopy = keyCopy;
- table->keyPrint = keyPrint;
- table->keyFree = keyFree;
+ table->keyCode = virHashStrCode;
+ table->keyEqual = virHashStrEqual;
+ table->keyCopy = virHashStrCopy;
+ table->keyPrint = virHashStrPrintHuman;
+ table->keyFree = virHashStrFree;
table->table = g_new0(virHashEntryPtr, table->size);
@@ -162,27 +150,6 @@ virHashTablePtr virHashCreateFull(ssize_t size,
}
-/**
- * virHashNew:
- * @dataFree: callback to free data
- *
- * Create a new virHashTablePtr.
- *
- * Returns the newly created object.
- */
-virHashTablePtr
-virHashNew(virHashDataFree dataFree)
-{
- return virHashCreateFull(32,
- dataFree,
- virHashStrCode,
- virHashStrEqual,
- virHashStrCopy,
- virHashStrPrintHuman,
- virHashStrFree);
-}
-
-
virHashAtomicPtr
virHashAtomicNew(virHashDataFree dataFree)
{
diff --git a/src/util/virhash.h b/src/util/virhash.h
index 2d221dce25..a9b022f362 100644
--- a/src/util/virhash.h
+++ b/src/util/virhash.h
@@ -113,13 +113,6 @@ typedef void (*virHashKeyFree)(void *name);
*/
virHashTablePtr virHashNew(virHashDataFree dataFree);
virHashAtomicPtr virHashAtomicNew(virHashDataFree dataFree);
-virHashTablePtr virHashCreateFull(ssize_t size,
- virHashDataFree dataFree,
- virHashKeyCode keyCode,
- virHashKeyEqual keyEqual,
- virHashKeyCopy keyCopy,
- virHashKeyPrintHuman keyPrint,
- virHashKeyFree keyFree);
void virHashFree(virHashTablePtr table);
ssize_t virHashSize(const virHashTable *table);
--
2.26.2