From: Peter Krempa Date: Tue, 20 Oct 2020 16:17:16 +0000 (+0200) Subject: util: hash: Remove virHashCreateFull X-Git-Tag: v6.9.0-rc1~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a2c699856a2c0d5c1bf0a4cef5ef767127a2274f;p=thirdparty%2Flibvirt.git util: hash: Remove virHashCreateFull 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 Reviewed-by: Pavel Hrdina --- 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);