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>
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;
static void *virHashStrCopy(const void *name)
{
- char *ret;
- ret = g_strdup(name);
- return ret;
+ return g_strdup(name);
}
* 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);
/**