mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
virhash: Fix the expectations of virHashKeyEqual implementations
Tweak the return value expectation comment so that it doesn't necessarily require to allocate memory and refactor the implementations. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
d69470a18a
commit
6cf3ec4428
@ -988,10 +988,7 @@ virZPCIAddrKeyEqual(const void *namea,
|
||||
static void *
|
||||
virZPCIAddrKeyCopy(const void *name)
|
||||
{
|
||||
unsigned int *copy;
|
||||
|
||||
if (VIR_ALLOC(copy) < 0)
|
||||
return NULL;
|
||||
unsigned int *copy = g_new0(unsigned int, 1);
|
||||
|
||||
*copy = *((unsigned int *)name);
|
||||
return (void *)copy;
|
||||
|
@ -94,9 +94,7 @@ static bool virHashStrEqual(const void *namea, const void *nameb)
|
||||
|
||||
static void *virHashStrCopy(const void *name)
|
||||
{
|
||||
char *ret;
|
||||
ret = g_strdup(name);
|
||||
return ret;
|
||||
return g_strdup(name);
|
||||
}
|
||||
|
||||
|
||||
|
@ -83,7 +83,8 @@ typedef bool (*virHashKeyEqual)(const void *namea, const void *nameb);
|
||||
* Create a copy of the hash key, duplicating
|
||||
* memory allocation where applicable
|
||||
*
|
||||
* Returns a newly allocated copy of @name
|
||||
* Returns a copy of @name which will eventually be passed to the
|
||||
* 'virHashKeyFree' callback at the end of its lifetime.
|
||||
*/
|
||||
typedef void *(*virHashKeyCopy)(const void *name);
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user