2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
6 <refentry id="sd_bus_slot_ref" xmlns:xi="http://www.w3.org/2001/XInclude">
8 <title>sd_bus_slot_ref</title>
9 <productname>systemd</productname>
13 <refentrytitle>sd_bus_slot_ref</refentrytitle>
14 <manvolnum>3</manvolnum>
18 <refname>sd_bus_slot_ref</refname>
19 <refname>sd_bus_slot_unref</refname>
20 <refname>sd_bus_slot_unrefp</refname>
22 <refpurpose>Create and destroy references to a bus slot object</refpurpose>
27 <funcsynopsisinfo>#include <systemd/sd-bus.h></funcsynopsisinfo>
30 <funcdef>sd_bus_slot *<function>sd_bus_slot_ref</function></funcdef>
31 <paramdef>sd_bus_slot *<parameter>slot</parameter></paramdef>
35 <funcdef>sd_bus_slot *<function>sd_bus_slot_unref</function></funcdef>
36 <paramdef>sd_bus_slot *<parameter>slot</parameter></paramdef>
40 <funcdef>void <function>sd_bus_slot_unrefp</function></funcdef>
41 <paramdef>sd_bus_slot **<parameter>slotp</parameter></paramdef>
47 <title>Description</title>
49 <para><function>sd_bus_slot_ref()</function> increases the internal reference counter of
50 <parameter>slot</parameter> by one.</para>
52 <para><function>sd_bus_slot_unref()</function> decreases the internal reference counter of
53 <parameter>slot</parameter> by one. Once the reference count has dropped to zero, slot object is
54 destroyed and cannot be used anymore, so further calls to <function>sd_bus_slot_ref()</function>
55 or <function>sd_bus_slot_unref()</function> are illegal.</para>
57 <para><function>sd_bus_slot_unrefp()</function> is similar to
58 <function>sd_bus_slot_unref()</function> but takes a pointer to a pointer to an
59 <type>sd_bus_slot</type> object. This call is useful in conjunction with GCC's and LLVM's <ulink
60 url="https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html">Clean-up Variable
61 Attribute</ulink>. See
62 <citerefentry><refentrytitle>sd_bus_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>
63 for an example how to use the cleanup attribute.</para>
65 <para><function>sd_bus_slot_ref()</function> and <function>sd_bus_slot_unref()</function>
66 execute no operation if the passed in bus object address is
67 <constant>NULL</constant>. <function>sd_bus_slot_unrefp()</function> will first dereference
68 its argument, which must not be <constant>NULL</constant>, and will execute no operation if
69 <emphasis>that</emphasis> is <constant>NULL</constant>.</para>
73 <title>Return Value</title>
75 <para><function>sd_bus_slot_ref()</function> always returns the argument.</para>
77 <para><function>sd_bus_slot_unref()</function> always returns <constant>NULL</constant>.</para>
80 <xi:include href="libsystemd-pkgconfig.xml" />
83 <title>History</title>
84 <para><function>sd_bus_slot_ref()</function>,
85 <function>sd_bus_slot_unref()</function>, and
86 <function>sd_bus_slot_unrefp()</function> were added in version 240.</para>
90 <title>See Also</title>
93 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
94 <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
95 <citerefentry><refentrytitle>sd_bus_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
96 <citerefentry><refentrytitle>sd_bus_message_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
97 <citerefentry><refentrytitle>sd_bus_call_method_async</refentrytitle><manvolnum>3</manvolnum></citerefentry>