我们需要对从 sd_device_enumerator_get_device_first 返回的 ref 调用 sd_device_unref 吗?
在从 sd_device_enumerator_get_device_first 返回的设备引用上调用 sd_device_unref(dev) 后,我注意到与内存相关的问题。
我没有看到 Systemd 测试用例中调用 sd_device_unref ,例如: https://github.com/systemd/systemd/blob/91010bd6ccd363be9e09f22c60d45f5e27c1d2a8/src/libsystemd/sd-device/test-sd-device.c#L362
我不认为是这样。因为当我这样做时,在枚举器上调用 sd_device_enumerator_unref 时会收到断言错误。
不幸的是,sd-device 根本没有很好的记录。