mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-23 11:52:20 +00:00
virHashAddOrUpdateEntry: Simplify allocation of new entry
Use g_new0 and skip checking of the return value of keyCopy callback as both are bound to return a valid pointer. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
6cf3ec4428
commit
509ddcfde2
@ -344,7 +344,6 @@ virHashAddOrUpdateEntry(virHashTablePtr table, const void *name,
|
||||
size_t key, len = 0;
|
||||
virHashEntryPtr entry;
|
||||
virHashEntryPtr last = NULL;
|
||||
void *new_name;
|
||||
|
||||
if ((table == NULL) || (name == NULL))
|
||||
return -1;
|
||||
@ -374,12 +373,8 @@ virHashAddOrUpdateEntry(virHashTablePtr table, const void *name,
|
||||
len++;
|
||||
}
|
||||
|
||||
if (VIR_ALLOC(entry) < 0 || !(new_name = table->keyCopy(name))) {
|
||||
VIR_FREE(entry);
|
||||
return -1;
|
||||
}
|
||||
|
||||
entry->name = new_name;
|
||||
entry = g_new0(virHashEntry, 1);
|
||||
entry->name = table->keyCopy(name);
|
||||
entry->payload = userdata;
|
||||
|
||||
if (last)
|
||||
|
Loading…
x
Reference in New Issue
Block a user