mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 21:34:54 +03:00
util: hash: Don't use 'const' with virHashTablePtr
We didn't use it rigorously and some helpers even cast it away. Remove const from all hash utility functions. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com> Reviewed-by: Matt Coleman <matt@datto.com>
This commit is contained in:
parent
247460ab41
commit
85d5b8bd9a
@ -983,7 +983,7 @@ virNWFilterVarAccessGetIntIterId(const virNWFilterVarAccess *vap)
|
||||
|
||||
bool
|
||||
virNWFilterVarAccessIsAvailable(const virNWFilterVarAccess *varAccess,
|
||||
const virHashTable *hash)
|
||||
virHashTablePtr hash)
|
||||
{
|
||||
const char *varName = virNWFilterVarAccessGetVarName(varAccess);
|
||||
const char *res;
|
||||
|
@ -119,7 +119,7 @@ virNWFilterVarAccessType virNWFilterVarAccessGetType(
|
||||
unsigned int virNWFilterVarAccessGetIterId(const virNWFilterVarAccess *vap);
|
||||
unsigned int virNWFilterVarAccessGetIndex(const virNWFilterVarAccess *vap);
|
||||
bool virNWFilterVarAccessIsAvailable(const virNWFilterVarAccess *vap,
|
||||
const virHashTable *hash);
|
||||
virHashTablePtr hash);
|
||||
|
||||
typedef struct _virNWFilterVarCombIterEntry virNWFilterVarCombIterEntry;
|
||||
typedef virNWFilterVarCombIterEntry *virNWFilterVarCombIterEntryPtr;
|
||||
|
@ -360,7 +360,8 @@ virHashGetEntry(const virHashTable *table,
|
||||
* Returns a pointer to the userdata
|
||||
*/
|
||||
void *
|
||||
virHashLookup(const virHashTable *table, const char *name)
|
||||
virHashLookup(virHashTablePtr table,
|
||||
const char *name)
|
||||
{
|
||||
virHashEntryPtr entry = virHashGetEntry(table, name);
|
||||
|
||||
@ -381,7 +382,7 @@ virHashLookup(const virHashTable *table, const char *name)
|
||||
* Returns true if the entry exists and false otherwise
|
||||
*/
|
||||
bool
|
||||
virHashHasEntry(const virHashTable *table,
|
||||
virHashHasEntry(virHashTablePtr table,
|
||||
const char *name)
|
||||
{
|
||||
return !!virHashGetEntry(table, name);
|
||||
@ -434,7 +435,7 @@ virHashAtomicSteal(virHashAtomicPtr table,
|
||||
* -1 in case of error
|
||||
*/
|
||||
ssize_t
|
||||
virHashSize(const virHashTable *table)
|
||||
virHashSize(virHashTablePtr table)
|
||||
{
|
||||
if (table == NULL)
|
||||
return -1;
|
||||
@ -652,15 +653,13 @@ virHashRemoveAll(virHashTablePtr table)
|
||||
* The elements are processed in a undefined order. Caller is
|
||||
* responsible for freeing the @name.
|
||||
*/
|
||||
void *virHashSearch(const virHashTable *ctable,
|
||||
void *virHashSearch(virHashTablePtr table,
|
||||
virHashSearcher iter,
|
||||
const void *opaque,
|
||||
char **name)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
/* Cast away const for internal detection of misuse. */
|
||||
virHashTablePtr table = (virHashTablePtr)ctable;
|
||||
|
||||
if (table == NULL || iter == NULL)
|
||||
return NULL;
|
||||
@ -739,7 +738,7 @@ virHashGetItems(virHashTablePtr table,
|
||||
struct virHashEqualData
|
||||
{
|
||||
bool equal;
|
||||
const virHashTable *table2;
|
||||
virHashTablePtr table2;
|
||||
virHashValueComparator compar;
|
||||
};
|
||||
|
||||
@ -760,8 +759,8 @@ static int virHashEqualSearcher(const void *payload, const char *name,
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool virHashEqual(const virHashTable *table1,
|
||||
const virHashTable *table2,
|
||||
bool virHashEqual(virHashTablePtr table1,
|
||||
virHashTablePtr table2,
|
||||
virHashValueComparator compar)
|
||||
{
|
||||
struct virHashEqualData data = {
|
||||
|
@ -60,7 +60,7 @@ typedef int (*virHashSearcher) (const void *payload, const char *name,
|
||||
virHashTablePtr virHashNew(virHashDataFree dataFree);
|
||||
virHashAtomicPtr virHashAtomicNew(virHashDataFree dataFree);
|
||||
void virHashFree(virHashTablePtr table);
|
||||
ssize_t virHashSize(const virHashTable *table);
|
||||
ssize_t virHashSize(virHashTablePtr table);
|
||||
|
||||
/*
|
||||
* Add a new entry to the hash table.
|
||||
@ -88,8 +88,8 @@ void virHashRemoveAll(virHashTablePtr table);
|
||||
/*
|
||||
* Retrieve the userdata.
|
||||
*/
|
||||
void *virHashLookup(const virHashTable *table, const char *name);
|
||||
bool virHashHasEntry(const virHashTable *table, const char *name);
|
||||
void *virHashLookup(virHashTablePtr table, const char *name);
|
||||
bool virHashHasEntry(virHashTablePtr table, const char *name);
|
||||
|
||||
/*
|
||||
* Retrieve & remove the userdata.
|
||||
@ -127,8 +127,8 @@ virHashKeyValuePairPtr virHashGetItems(virHashTablePtr table,
|
||||
* of two keys.
|
||||
*/
|
||||
typedef int (*virHashValueComparator)(const void *value1, const void *value2);
|
||||
bool virHashEqual(const virHashTable *table1,
|
||||
const virHashTable *table2,
|
||||
bool virHashEqual(virHashTablePtr table1,
|
||||
virHashTablePtr table2,
|
||||
virHashValueComparator compar);
|
||||
|
||||
|
||||
@ -139,7 +139,7 @@ int virHashForEach(virHashTablePtr table, virHashIterator iter, void *opaque);
|
||||
int virHashForEachSafe(virHashTablePtr table, virHashIterator iter, void *opaque);
|
||||
int virHashForEachSorted(virHashTablePtr table, virHashIterator iter, void *opaque);
|
||||
ssize_t virHashRemoveSet(virHashTablePtr table, virHashSearcher iter, const void *opaque);
|
||||
void *virHashSearch(const virHashTable *table, virHashSearcher iter,
|
||||
void *virHashSearch(virHashTablePtr table, virHashSearcher iter,
|
||||
const void *opaque, char **name);
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virHashTable, virHashFree);
|
||||
|
Loading…
Reference in New Issue
Block a user