diff --git a/man/rules/meson.build b/man/rules/meson.build
index 180b0abaaa..55376c0ecc 100644
--- a/man/rules/meson.build
+++ b/man/rules/meson.build
@@ -516,6 +516,7 @@ manpages = [
'sd_device_get_sysname',
'sd_device_get_sysnum'],
''],
+ ['sd_device_ref', '3', ['sd_device_unref', 'sd_device_unrefp'], ''],
['sd_event_add_child',
'3',
['sd_event_add_child_pidfd',
diff --git a/man/sd-device.xml b/man/sd-device.xml
index 3a86a28848..7af839b4bd 100644
--- a/man/sd-device.xml
+++ b/man/sd-device.xml
@@ -42,7 +42,8 @@
libudev.h.
See
- sd_device_get_syspath3
+ sd_device_get_syspath3,
+sd_device_ref3
for more information about the functions available.
diff --git a/man/sd_bus_new.xml b/man/sd_bus_new.xml
index 355b34bad8..41964640b6 100644
--- a/man/sd_bus_new.xml
+++ b/man/sd_bus_new.xml
@@ -109,7 +109,7 @@
pointer to an sd_bus object. This call is useful in
conjunction with GCC's and LLVM's Clean-up
- Variable Attribute. Note that this function is defined as
+ Variable Attribute. Note that this function is defined as an
inline function. Use a declaration like the following, in order to
allocate a bus object that is freed automatically as the code
block is left:
@@ -124,12 +124,10 @@
…
}
- sd_bus_ref() and sd_bus_unref()
- execute no operation if the passed in bus object address is
- NULL. sd_bus_unrefp() will first
- dereference its argument, which must not be NULL, and will
- execute no operation if that is NULL.
-
+ sd_bus_ref() and sd_bus_unref() execute no operation if
+ the argument is NULL. sd_bus_unrefp() will first dereference
+ its argument, which must not be NULL, and will execute no operation if
+ that is NULL.
sd_bus_close_unref() is similar to sd_bus_unref(), but
first executes
diff --git a/man/sd_device_ref.xml b/man/sd_device_ref.xml
new file mode 100644
index 0000000000..b7ed4d985c
--- /dev/null
+++ b/man/sd_device_ref.xml
@@ -0,0 +1,83 @@
+
+
+
+
+
+
+ sd_device_ref
+ systemd
+
+
+
+ sd_device_ref
+ 3
+
+
+
+ sd_device_ref
+ sd_device_unref
+ sd_device_unrefp
+
+ Create or destroy references to a device object
+
+
+
+
+ #include <systemd/sd-device.h>
+
+
+ sd_device* sd_device_ref
+ sd_device *device
+
+
+
+ sd_device* sd_device_unref
+ sd_device *device
+
+
+
+ void sd_device_unrefp
+ sd_device **device
+
+
+
+ sd_device_ref() increases the reference counter of
+ device by one.
+
+ sd_device_unref() decreases the reference counter of
+ device by one. Once the reference count has dropped to zero,
+ device is destroyed and cannot be used anymore, so further calls to
+ sd_device_ref() or sd_device_unref() are illegal.
+
+ sd_device_unrefp() is similar to sd_device_unref() but
+ takes a pointer to a pointer to an sd_device object. This call is useful in conjunction with
+ GCC's and LLVM's Clean-up
+ Variable Attribute. Note that this function is defined as an inline function. Use a declaration
+ like the following, in order to allocate a device object that is freed automatically as the code block is
+ left:
+
+ {
+ __attribute__((cleanup(sd_device_unrefp))) sd_device *device = NULL;
+ int r;
+ …
+ r = sd_device_new_from_syspath(&device, "…");
+ if (r < 0)
+ fprintf(stderr, "Failed to allocate device: %s\n", strerror(-r));
+ …
+}
+
+ sd_device_ref() and sd_device_unref() execute no
+ operation if the argument is NULL. sd_device_unrefp() will
+ first dereference its argument, which must not be NULL, and will execute no
+ operation if that is NULL.
+
+
+
+ Return Value
+
+ sd_device_ref() always returns the argument, and
+ sd_device_unref() always returns NULL.
+
+
+