tests: drop the .dispose() method from gpiosim-glib's chip class
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Wed, 1 Feb 2023 08:34:30 +0000 (09:34 +0100)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Wed, 1 Feb 2023 08:34:30 +0000 (09:34 +0100)
The .dispose() method should be used to drop references to any other
GObjects while .finalize() should free any remaining memory. While we are
dropping references in .dispose(), these are references to the libgpiosim
objects that are also guaranteed to always be at most equal 1. Move the
reference drops to .finalize() and remove .dispose() entirely.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
tests/gpiod-test-sim.c

index 50003b54b2bf757586381df2fce336d418f8118e..b934a16da81517922cefaa58a1f7d4fccaffbcab 100644 (file)
@@ -158,7 +158,7 @@ static void g_gpiosim_chip_set_property(GObject *obj, guint prop_id,
        }
 }
 
-static void g_gpiosim_chip_dispose(GObject *obj)
+static void g_gpiosim_chip_finalize(GObject *obj)
 {
        GPIOSimChip *self = G_GPIOSIM_CHIP(obj);
        struct gpiosim_dev *dev;
@@ -174,12 +174,6 @@ static void g_gpiosim_chip_dispose(GObject *obj)
        }
 
        gpiosim_dev_unref(dev);
-}
-
-static void g_gpiosim_chip_finalize(GObject *obj)
-{
-       GPIOSimChip *self = G_GPIOSIM_CHIP(obj);
-
        gpiosim_bank_unref(self->bank);
 
        G_OBJECT_CLASS(g_gpiosim_chip_parent_class)->finalize(obj);
@@ -192,7 +186,6 @@ static void g_gpiosim_chip_class_init(GPIOSimChipClass *chip_class)
        class->constructed = g_gpiosim_chip_constructed;
        class->get_property = g_gpiosim_chip_get_property;
        class->set_property = g_gpiosim_chip_set_property;
-       class->dispose = g_gpiosim_chip_dispose;
        class->finalize = g_gpiosim_chip_finalize;
 
        g_object_class_install_property(