treewide: init assignment lists head
[oweals/odhcpd.git] / src / odhcpd.h
index 9535e752a12c61d3f2a61323757a301e90f32916..37a5a4a4c6e448683f7f4daae924e3d84b983059 100644 (file)
@@ -309,11 +309,8 @@ extern struct avl_tree interfaces;
 
 inline static void free_assignment(struct dhcp_assignment *a)
 {
-       if (a->head.next)
-               list_del(&a->head);
-
-       if (a->lease_list.next)
-               list_del(&a->lease_list);
+       list_del(&a->head);
+       list_del(&a->lease_list);
 
        if (a->dhcp_free_cb)
                a->dhcp_free_cb(a);
@@ -323,6 +320,19 @@ inline static void free_assignment(struct dhcp_assignment *a)
        free(a);
 }
 
+inline static struct dhcp_assignment *alloc_assignment(size_t extra_len)
+{
+       struct dhcp_assignment *a = calloc(1, sizeof(*a) + extra_len);
+
+       if (!a)
+               return NULL;
+
+       INIT_LIST_HEAD(&a->head);
+       INIT_LIST_HEAD(&a->lease_list);
+
+       return a;
+}
+
 // Exported main functions
 int odhcpd_register(struct odhcpd_event *event);
 int odhcpd_deregister(struct odhcpd_event *event);