diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index c0e468122a4d7a84d7aad0147bab17850bc4faac..e8629b3ed8fd668be8f577412d833fb676de5924 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -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; diff --git a/src/util/virhash.c b/src/util/virhash.c index d5c5e017a14f988f50c4b0b34dc7cd71195186c8..c57d9f8292de695224ced5307673cd7a26d0d6a8 100644 --- a/src/util/virhash.c +++ b/src/util/virhash.c @@ -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); } diff --git a/src/util/virhash.h b/src/util/virhash.h index 08f99d8a3d063d90e63d33f1c5508ead27e51ed9..cb59fb639ba0c855530d62215257a7ed794693f2 100644 --- a/src/util/virhash.h +++ b/src/util/virhash.h @@ -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); /**