On 06/22/2018 12:42 AM, Chris Venteicher wrote: > Init - Initial with model name and empty properties > FreeContents - Free model name and properties without freeing pointer > --- > src/qemu/qemu_monitor.c | 37 ++++++++++++++++++++++++++++++++++++- > src/qemu/qemu_monitor.h | 4 ++++ > 2 files changed, 40 insertions(+), 1 deletion(-) > > diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c > index d6771c1d52..16de54dac7 100644 > --- a/src/qemu/qemu_monitor.c > +++ b/src/qemu/qemu_monitor.c > @@ -3632,8 +3632,31 @@ qemuMonitorGetCPUModelExpansion(qemuMonitorPtr mon, > } > > > +int > +qemuMonitorCPUModelInfoInit(const char *name, qemuMonitorCPUModelInfoPtr model) > +{ > + int ret = -1; > + > + if (!model) > + goto cleanup; > + > + model->name = NULL; > + model->nprops = 0; > + model->props = NULL; > + model->props_migratable_valid = false; > + > + if (VIR_STRDUP(model->name, name) < 0) > + goto cleanup; > + > + ret = 0; > + > + cleanup: > + return ret; > +} > +> + > void > -qemuMonitorCPUModelInfoFree(qemuMonitorCPUModelInfoPtr model_info) > +qemuMonitorCPUModelInfoFreeContents(qemuMonitorCPUModelInfoPtr model_info) > { > size_t i; > > @@ -3648,6 +3671,18 @@ qemuMonitorCPUModelInfoFree(qemuMonitorCPUModelInfoPtr model_info) > > VIR_FREE(model_info->props); > VIR_FREE(model_info->name); > + > + model_info->name = NULL; > + model_info->nprops = 0; > + model_info->props = NULL; > + model_info->props_migratable_valid = false; > +} I thought VIR_FREE frees memory and then updates the pointer to NULL? > + > + > +void > +qemuMonitorCPUModelInfoFree(qemuMonitorCPUModelInfoPtr model_info) > +{ > + qemuMonitorCPUModelInfoFreeContents(model_info); > VIR_FREE(model_info); > } > > diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h > index b3d62324b4..7dbc993f1b 100644 > --- a/src/qemu/qemu_monitor.h > +++ b/src/qemu/qemu_monitor.h > @@ -1021,6 +1021,10 @@ int qemuMonitorGetCPUModelExpansion(qemuMonitorPtr mon, > qemuMonitorCPUModelInfoPtr *model_info); > > void qemuMonitorCPUModelInfoFree(qemuMonitorCPUModelInfoPtr model_info); > +void qemuMonitorCPUModelInfoFreeContents(qemuMonitorCPUModelInfoPtr model_info); > + > +int qemuMonitorCPUModelInfoInit(const char *name, qemuMonitorCPUModelInfoPtr model) > + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); > > qemuMonitorCPUModelInfoPtr > qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUModelInfo *orig); > -- Respectfully, - Collin Walling -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list