These objects are only useful when multiple threads are involved, as they
operate with atomic operations. Given that our libraries are explicitly not
thread-safe don't make use of RefCnt here, and make things a bit simpler.
#include "in-addr-util.h"
#include "list.h"
#include "random-util.h"
-#include "refcnt.h"
#include "siphash24.h"
#include "util.h"
} IPv4ACDState;
struct sd_ipv4acd {
- RefCount n_ref;
+ unsigned n_ref;
IPv4ACDState state;
int ifindex;
};
sd_ipv4acd *sd_ipv4acd_ref(sd_ipv4acd *ll) {
- if (ll)
- assert_se(REFCNT_INC(ll->n_ref) >= 2);
+ if (!ll)
+ return NULL;
+
+ assert_se(ll->n_ref >= 1);
+ ll->n_ref++;
return ll;
}
sd_ipv4acd *sd_ipv4acd_unref(sd_ipv4acd *ll) {
- if (!ll || REFCNT_DEC(ll->n_ref) > 0)
+ if (!ll)
+ return NULL;
+
+ assert_se(ll->n_ref >= 1);
+ ll->n_ref--;
+
+ if (ll->n_ref > 0)
return NULL;
ll->receive_message = sd_event_source_unref(ll->receive_message);
if (!ll)
return -ENOMEM;
- ll->n_ref = REFCNT_INIT;
+ ll->n_ref = 1;
ll->state = IPV4ACD_STATE_INIT;
ll->ifindex = -1;
ll->fd = -1;
#include "in-addr-util.h"
#include "list.h"
#include "random-util.h"
-#include "refcnt.h"
#include "siphash24.h"
#include "sparse-endian.h"
#include "util.h"