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_Data %s_Data;\n" % (self.name, self.name)
|
||||
typedef += "G_DEFINE_AUTOPTR_CLEANUP_FUNC(%s, hypervFreeObject);\n" % self.name
|
||||
typedef += "\n"
|
||||
|
||||
return typedef
|
||||
|
||||
@ -308,6 +310,8 @@ def main():
|
||||
classes_header.write(notice)
|
||||
classes_source.write(notice)
|
||||
|
||||
classes_typedef.write("void hypervFreeObject(void *object);\n\n\n")
|
||||
|
||||
names = sorted(wmi_classes_by_name.keys())
|
||||
|
||||
for name in names:
|
||||
|
@ -1068,7 +1068,7 @@ hypervEnumAndPull(hypervPrivate *priv, hypervWqlQueryPtr wqlQuery,
|
||||
|
||||
|
||||
void
|
||||
hypervFreeObject(hypervObject *object)
|
||||
hypervFreeObject(void *object)
|
||||
{
|
||||
hypervObject *next;
|
||||
WsSerializerContextH serializerContext;
|
||||
@ -1076,15 +1076,15 @@ hypervFreeObject(hypervObject *object)
|
||||
if (object == NULL)
|
||||
return;
|
||||
|
||||
serializerContext = wsmc_get_serialization_context(object->priv->client);
|
||||
serializerContext = wsmc_get_serialization_context(((hypervObject *)object)->priv->client);
|
||||
|
||||
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,
|
||||
object->info->serializerInfo) < 0) {
|
||||
if (ws_serializer_free_mem(serializerContext, ((hypervObject *)object)->data,
|
||||
((hypervObject *)object)->info->serializerInfo) < 0) {
|
||||
VIR_ERROR(_("Could not free deserialized data"));
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ struct _hypervWqlQuery {
|
||||
int hypervEnumAndPull(hypervPrivate *priv, hypervWqlQueryPtr wqlQuery,
|
||||
hypervObject **list);
|
||||
|
||||
void hypervFreeObject(hypervObject *object);
|
||||
void hypervFreeObject(void *object);
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(hypervObject, hypervFreeObject);
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user