1<?xml version='1.0'?> 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 --> 5 6<refentry id="sd_bus_slot_set_destroy_callback" 7 xmlns:xi="http://www.w3.org/2001/XInclude"> 8 9 <refentryinfo> 10 <title>sd_bus_slot_set_destroy_callback</title> 11 <productname>systemd</productname> 12 </refentryinfo> 13 14 <refmeta> 15 <refentrytitle>sd_bus_slot_set_destroy_callback</refentrytitle> 16 <manvolnum>3</manvolnum> 17 </refmeta> 18 19 <refnamediv> 20 <refname>sd_bus_slot_set_destroy_callback</refname> 21 <refname>sd_bus_slot_get_destroy_callback</refname> 22 <refname>sd_bus_track_set_destroy_callback</refname> 23 <refname>sd_bus_track_get_destroy_callback</refname> 24 <refname>sd_bus_destroy_t</refname> 25 26 <refpurpose>Define the callback function for resource cleanup</refpurpose> 27 </refnamediv> 28 29 <refsynopsisdiv> 30 <funcsynopsis> 31 <funcsynopsisinfo>#include <systemd/sd-bus.h></funcsynopsisinfo> 32 33 <funcprototype> 34 <funcdef>typedef int (*<function>sd_bus_destroy_t</function>)</funcdef> 35 <paramdef>void *<parameter>userdata</parameter></paramdef> 36 </funcprototype> 37 38 <funcprototype> 39 <funcdef>int <function>sd_bus_slot_set_destroy_callback</function></funcdef> 40 <paramdef>sd_bus_slot *<parameter>slot</parameter></paramdef> 41 <paramdef>sd_bus_destroy_t <parameter>callback</parameter></paramdef> 42 </funcprototype> 43 44 <funcprototype> 45 <funcdef>int <function>sd_bus_slot_get_destroy_callback</function></funcdef> 46 <paramdef>sd_bus_slot *<parameter>slot</parameter></paramdef> 47 <paramdef>sd_bus_destroy_t *<parameter>callback</parameter></paramdef> 48 </funcprototype> 49 50 <funcprototype> 51 <funcdef>int <function>sd_bus_track_set_destroy_callback</function></funcdef> 52 <paramdef>sd_bus_track *<parameter>track</parameter></paramdef> 53 <paramdef>sd_bus_destroy_t <parameter>callback</parameter></paramdef> 54 </funcprototype> 55 56 <funcprototype> 57 <funcdef>int <function>sd_bus_track_get_destroy_callback</function></funcdef> 58 <paramdef>sd_bus_track *<parameter>track</parameter></paramdef> 59 <paramdef>sd_bus_destroy_t *<parameter>callback</parameter></paramdef> 60 </funcprototype> 61 </funcsynopsis> 62 </refsynopsisdiv> 63 64 <refsect1> 65 <title>Description</title> 66 67 <para><function>sd_bus_slot_set_destroy_callback()</function> sets <parameter>callback</parameter> as the callback 68 function to be called right before the bus slot object <parameter>slot</parameter> is deallocated. The 69 <parameter>userdata</parameter> pointer from the slot object will be passed as the <parameter>userdata</parameter> 70 parameter. This pointer can be set by an argument to the constructor functions, see 71 <citerefentry><refentrytitle>sd_bus_add_match</refentrytitle><manvolnum>3</manvolnum></citerefentry>, or directly, 72 see <citerefentry><refentrytitle>sd_bus_slot_set_userdata</refentrytitle><manvolnum>3</manvolnum></citerefentry>. 73 This callback function is called even if <parameter>userdata</parameter> is <constant>NULL</constant>. Note that 74 this callback is invoked at a time where the bus slot object itself is already invalidated, and executing 75 operations or taking new references to the bus slot object is not permissible.</para> 76 77 <para><function>sd_bus_slot_get_destroy_callback()</function> returns the current callback 78 for <parameter>slot</parameter> in the <parameter>callback</parameter> parameter.</para> 79 80 <para><function>sd_bus_track_set_destroy_callback()</function> and 81 <function>sd_bus_track_get_destroy_callback()</function> provide equivalent functionality for the 82 <parameter>userdata</parameter> pointer associated with bus peer tracking objects. For details about bus peer 83 tracking objects, see 84 <citerefentry><refentrytitle>sd_bus_track_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para> 85 </refsect1> 86 87 <refsect1> 88 <title>Return Value</title> 89 90 <para>On success, <function>sd_bus_slot_set_destroy_callback()</function> and 91 <function>sd_bus_track_set_destroy_callback()</function> return 0 or a positive integer. On failure, they 92 return a negative errno-style error code.</para> 93 94 <para><function>sd_bus_slot_get_destroy_callback()</function> and 95 <function>sd_bus_track_get_destroy_callback()</function> return positive if the destroy callback function 96 is set, 0 if not. On failure, they return a negative errno-style error code.</para> 97 98 <refsect2> 99 <title>Errors</title> 100 101 <para>Returned errors may indicate the following problems:</para> 102 103 <variablelist> 104 <varlistentry> 105 <term><constant>-EINVAL</constant></term> 106 107 <listitem><para>The <parameter>slot</parameter> or <parameter>track</parameter> parameter is 108 <constant>NULL</constant>.</para></listitem> 109 </varlistentry> 110 </variablelist> 111 </refsect2> 112 </refsect1> 113 114 <xi:include href="libsystemd-pkgconfig.xml" /> 115 116 <refsect1> 117 <title>See Also</title> 118 119 <para> 120 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, 121 <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>, 122 <citerefentry><refentrytitle>sd_bus_slot_set_floating</refentrytitle><manvolnum>3</manvolnum></citerefentry>, 123 <citerefentry><refentrytitle>sd_bus_add_match</refentrytitle><manvolnum>3</manvolnum></citerefentry>, 124 <citerefentry><refentrytitle>sd_bus_track_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>, 125 <citerefentry><refentrytitle>sd_bus_slot_set_userdata</refentrytitle><manvolnum>3</manvolnum></citerefentry>, 126 <citerefentry><refentrytitle>sd_bus_track_set_userdata</refentrytitle><manvolnum>3</manvolnum></citerefentry> 127 </para> 128 </refsect1> 129 130</refentry> 131