fp-context, tools: Use auto-ptr to handle GTypeClass ownership

This also fixes a small leak we might have if reffing a type that was not a
virtual one.
This commit is contained in:
Marco Trevisan (Treviño)
2019-12-13 20:40:41 +01:00
parent 43a8c909bf
commit eeddd8c7bc
3 changed files with 11 additions and 24 deletions

View File

@@ -104,17 +104,13 @@ main (int argc, char **argv)
for (i = 0; i < drivers->len; i++)
{
GType driver = g_array_index (drivers, GType, i);
FpDeviceClass *cls = FP_DEVICE_CLASS (g_type_class_ref (driver));
g_autoptr(GTypeClass) type_class = g_type_class_ref (driver);
FpDeviceClass *cls = FP_DEVICE_CLASS (type_class);
if (cls->type != FP_DEVICE_TYPE_USB)
{
g_type_class_unref (cls);
continue;
}
continue;
print_driver (cls);
g_type_class_unref (cls);
}
print_driver (&whitelist);