---
name: "sd_bus_slot_unref"
section: "3"
platform: "linux"
package: "libsystemd-dev"
version: "257.13-1~deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/sd_bus_slot_ref"
---

# sd\_bus\_slot\_unref(3)

Create and destroy references to a bus slot object

Part of [sd\_bus\_slot\_ref(3)](/sd_bus_slot_ref/3.md).

## NAME

sd\_bus\_slot\_ref, sd\_bus\_slot\_unref, sd\_bus\_slot\_unrefp - Create and destroy references to a bus slot object

## SYNOPSIS

```
#include <systemd/sd-bus.h>
```

**sd\_bus\_slot \*sd\_bus\_slot\_ref(sd\_bus\_slot \****slot***);**

**sd\_bus\_slot \*sd\_bus\_slot\_unref(sd\_bus\_slot \****slot***);**

**void sd\_bus\_slot\_unrefp(sd\_bus\_slot \*\****slotp***);**

## DESCRIPTION

**sd\_bus\_slot\_ref()** increases the internal reference counter of *slot* by one.

**sd\_bus\_slot\_unref()** decreases the internal reference counter of *slot* by one. Once the reference count has dropped to zero, slot object is destroyed and cannot be used anymore, so further calls to **sd\_bus\_slot\_ref()** or **sd\_bus\_slot\_unref()** are illegal.

**sd\_bus\_slot\_unrefp()** is similar to **sd\_bus\_slot\_unref()** but takes a pointer to a pointer to an **sd\_bus\_slot** object. This call is useful in conjunction with GCC's and LLVM's **Clean-up Variable Attribute**\[1\]. See [**sd\_bus\_new**(3)](/sd_bus_new/3.md) for an example how to use the cleanup attribute.

**sd\_bus\_slot\_ref()** and **sd\_bus\_slot\_unref()** execute no operation if the passed in bus object address is **NULL**. **sd\_bus\_slot\_unrefp()** will first dereference its argument, which must not be **NULL**, and will execute no operation if *that* is **NULL**.

## RETURN VALUE

**sd\_bus\_slot\_ref()** always returns the argument.

**sd\_bus\_slot\_unref()** always returns **NULL**.

## NOTES

Functions described here are available as a shared library, which can be compiled against and linked to with the **libsystemd** [**pkg-config**(1)](/pkg-config/1.md) file.

The code described here uses [**getenv**(3)](/getenv/3.md), which is declared to be not multi-thread-safe. This means that the code calling the functions described here must not call [**setenv**(3)](/setenv/3.md) from a parallel thread. It is recommended to only do calls to **setenv()** from an early phase of the program when no other threads have been started.

## HISTORY

**sd\_bus\_slot\_ref()**, **sd\_bus\_slot\_unref()**, and **sd\_bus\_slot\_unrefp()** were added in version 240.

## SEE ALSO

[**systemd**(1)](/systemd/1.md), [**sd-bus**(3)](/sd-bus/3.md), [**sd\_bus\_new**(3)](/sd_bus_new/3.md), [**sd\_bus\_message\_new**(3)](/sd_bus_message_new/3.md), [**sd\_bus\_call\_method\_async**(3)](/sd_bus_call_method_async/3.md)

## NOTES

- 1\.

  Clean-up Variable Attribute

  https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html
