summaryrefslogtreecommitdiff
path: root/src/libsystemd-network/sd-dhcp-lease.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2018-08-27 14:01:46 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2018-08-27 14:01:46 +0900
commit8301aa0bf145099e55443b8c10d00a62d20e0d29 (patch)
treedee970b9c80b599a83143e255d634e1293c89254 /src/libsystemd-network/sd-dhcp-lease.c
parenta6a08596ef8f3b33677704e72f51f9765af59bb4 (diff)
downloadsystemd-8301aa0bf145099e55443b8c10d00a62d20e0d29.tar.gz
tree-wide: use DEFINE_TRIVIAL_REF_UNREF_FUNC() macro or friends where applicable
Diffstat (limited to 'src/libsystemd-network/sd-dhcp-lease.c')
-rw-r--r--src/libsystemd-network/sd-dhcp-lease.c25
1 files changed, 4 insertions, 21 deletions
diff --git a/src/libsystemd-network/sd-dhcp-lease.c b/src/libsystemd-network/sd-dhcp-lease.c
index 8b6f5ad34f..a65e6166fb 100644
--- a/src/libsystemd-network/sd-dhcp-lease.c
+++ b/src/libsystemd-network/sd-dhcp-lease.c
@@ -246,27 +246,8 @@ int sd_dhcp_lease_get_vendor_specific(sd_dhcp_lease *lease, const void **data, s
return 0;
}
-sd_dhcp_lease *sd_dhcp_lease_ref(sd_dhcp_lease *lease) {
-
- if (!lease)
- return NULL;
-
- assert(lease->n_ref >= 1);
- lease->n_ref++;
-
- return lease;
-}
-
-sd_dhcp_lease *sd_dhcp_lease_unref(sd_dhcp_lease *lease) {
-
- if (!lease)
- return NULL;
-
- assert(lease->n_ref >= 1);
- lease->n_ref--;
-
- if (lease->n_ref > 0)
- return NULL;
+static sd_dhcp_lease *dhcp_lease_free(sd_dhcp_lease *lease) {
+ assert(lease);
while (lease->private_options) {
struct sd_dhcp_raw_option *option = lease->private_options;
@@ -288,6 +269,8 @@ sd_dhcp_lease *sd_dhcp_lease_unref(sd_dhcp_lease *lease) {
return mfree(lease);
}
+DEFINE_TRIVIAL_REF_UNREF_FUNC(sd_dhcp_lease, sd_dhcp_lease, dhcp_lease_free);
+
static int lease_parse_u32(const uint8_t *option, size_t len, uint32_t *ret, uint32_t min) {
assert(option);
assert(ret);