#include "netlink-internal.h"
#include "netlink-types.h"
#include "netlink-util.h"
-#include "refcnt.h"
#include "socket-util.h"
#include "util.h"
if (!m)
return -ENOMEM;
- m->n_ref = REFCNT_INIT;
+ m->n_ref = 1;
m->protocol = rtnl->protocol;
m->sealed = false;
return 0;
}
-DEFINE_ATOMIC_REF_FUNC(sd_netlink_message, sd_netlink_message);
+DEFINE_TRIVIAL_REF_FUNC(sd_netlink_message, sd_netlink_message);
sd_netlink_message *sd_netlink_message_unref(sd_netlink_message *m) {
- sd_netlink_message *t;
-
- while (m && REFCNT_DEC(m->n_ref) == 0) {
+ while (m && --m->n_ref == 0) {
unsigned i;
free(m->hdr);
for (i = 0; i <= m->n_containers; i++)
free(m->containers[i].attributes);
- t = m;
+ sd_netlink_message *t = m;
m = m->next;
free(t);
}
return -ENOMEM;
*rtnl = (sd_netlink) {
- .n_ref = REFCNT_INIT,
+ .n_ref = 1,
.fd = -1,
.sockaddr.nl.nl_family = AF_NETLINK,
.original_pid = getpid_cached(),
return mfree(rtnl);
}
-DEFINE_ATOMIC_REF_UNREF_FUNC(sd_netlink, sd_netlink, netlink_free);
+DEFINE_TRIVIAL_REF_UNREF_FUNC(sd_netlink, sd_netlink, netlink_free);
static void rtnl_seal_message(sd_netlink *rtnl, sd_netlink_message *m) {
assert(rtnl);