diff options
author | Hans Dedecker <dedeckeh@gmail.com> | 2016-12-29 15:17:13 +0100 |
---|---|---|
committer | Hans Dedecker <dedeckeh@gmail.com> | 2016-12-29 15:28:57 +0100 |
commit | bf4ebc0bf37c0a0dce6143f8db70b0bef40332d2 (patch) | |
tree | 89e8f3cf6304fef78cdee0bd4aef72c4036c10d9 /src | |
parent | c24782ada0932c25fd4063d4102670c79bbcf917 (diff) |
config: use free_lease to delete a lease
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/config.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/config.c b/src/config.c index daf583b..e3bf78a 100644 --- a/src/config.c +++ b/src/config.c @@ -162,6 +162,15 @@ static int mkdir_p(char *dir, mode_t mask) return ret; } +static void free_lease(struct lease *l) +{ + if (l->head.next) + list_del(&l->head); + + free(l->duid); + free(l); +} + static struct interface* get_interface(const char *name) { struct interface *c; @@ -323,10 +332,9 @@ static int set_lease(struct uci_section *s) return 0; err: - if (lease) { - free(lease->duid); - free(lease); - } + if (lease) + free_lease(lease); + return -1; } @@ -607,12 +615,8 @@ void odhcpd_reload(void) { struct uci_context *uci = uci_alloc_context(); - while (!list_empty(&leases)) { - struct lease *l = list_first_entry(&leases, struct lease, head); - list_del(&l->head); - free(l->duid); - free(l); - } + while (!list_empty(&leases)) + free_lease(list_first_entry(&leases, struct lease, head)); struct interface *master = NULL, *i, *n; |