mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
hyperv: enable use of g_autoptr for the rest of the CIM/WMI classes
Signed-off-by: Matt Coleman <matt@datto.com> Reviewed-by: Laine Stump <laine@redhat.com>
This commit is contained in:
parent
e668d4a57d
commit
a245dbdd4a
@ -98,6 +98,8 @@ class WmiClass:
|
|||||||
|
|
||||||
typedef = "typedef struct _%s %s;\n" % (self.name, self.name)
|
typedef = "typedef struct _%s %s;\n" % (self.name, self.name)
|
||||||
typedef += "typedef struct _%s_Data %s_Data;\n" % (self.name, self.name)
|
typedef += "typedef struct _%s_Data %s_Data;\n" % (self.name, self.name)
|
||||||
|
typedef += "G_DEFINE_AUTOPTR_CLEANUP_FUNC(%s, hypervFreeObject);\n" % self.name
|
||||||
|
typedef += "\n"
|
||||||
|
|
||||||
return typedef
|
return typedef
|
||||||
|
|
||||||
@ -308,6 +310,8 @@ def main():
|
|||||||
classes_header.write(notice)
|
classes_header.write(notice)
|
||||||
classes_source.write(notice)
|
classes_source.write(notice)
|
||||||
|
|
||||||
|
classes_typedef.write("void hypervFreeObject(void *object);\n\n\n")
|
||||||
|
|
||||||
names = sorted(wmi_classes_by_name.keys())
|
names = sorted(wmi_classes_by_name.keys())
|
||||||
|
|
||||||
for name in names:
|
for name in names:
|
||||||
|
@ -1068,7 +1068,7 @@ hypervEnumAndPull(hypervPrivate *priv, hypervWqlQueryPtr wqlQuery,
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
hypervFreeObject(hypervObject *object)
|
hypervFreeObject(void *object)
|
||||||
{
|
{
|
||||||
hypervObject *next;
|
hypervObject *next;
|
||||||
WsSerializerContextH serializerContext;
|
WsSerializerContextH serializerContext;
|
||||||
@ -1076,15 +1076,15 @@ hypervFreeObject(hypervObject *object)
|
|||||||
if (object == NULL)
|
if (object == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
serializerContext = wsmc_get_serialization_context(object->priv->client);
|
serializerContext = wsmc_get_serialization_context(((hypervObject *)object)->priv->client);
|
||||||
|
|
||||||
while (object != NULL) {
|
while (object != NULL) {
|
||||||
next = object->next;
|
next = ((hypervObject *)object)->next;
|
||||||
|
|
||||||
object->priv = NULL;
|
((hypervObject *)object)->priv = NULL;
|
||||||
|
|
||||||
if (ws_serializer_free_mem(serializerContext, object->data,
|
if (ws_serializer_free_mem(serializerContext, ((hypervObject *)object)->data,
|
||||||
object->info->serializerInfo) < 0) {
|
((hypervObject *)object)->info->serializerInfo) < 0) {
|
||||||
VIR_ERROR(_("Could not free deserialized data"));
|
VIR_ERROR(_("Could not free deserialized data"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ struct _hypervWqlQuery {
|
|||||||
int hypervEnumAndPull(hypervPrivate *priv, hypervWqlQueryPtr wqlQuery,
|
int hypervEnumAndPull(hypervPrivate *priv, hypervWqlQueryPtr wqlQuery,
|
||||||
hypervObject **list);
|
hypervObject **list);
|
||||||
|
|
||||||
void hypervFreeObject(hypervObject *object);
|
void hypervFreeObject(void *object);
|
||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(hypervObject, hypervFreeObject);
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(hypervObject, hypervFreeObject);
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user