void cgroup_context_remove_socket_bind(CGroupSocketBindItem **head) {
assert(head);
- while (*head) {
- CGroupSocketBindItem *h = *head;
- LIST_REMOVE(socket_bind_items, *head, h);
- free(h);
- }
+ LIST_CLEAR(socket_bind_items, *head, free);
}
void cgroup_context_done(CGroupContext *c) {
}
void socket_free_ports(Socket *s) {
- SocketPort *p;
-
assert(s);
- while ((p = s->ports)) {
- LIST_REMOVE(port, s->ports, p);
- socket_port_free(p);
- }
+ LIST_CLEAR(port, s->ports, socket_port_free);
}
static void socket_done(Unit *u) {
if (!ra)
return NULL;
- while (ra->prefixes) {
- sd_radv_prefix *p = ra->prefixes;
-
- LIST_REMOVE(prefix, ra->prefixes, p);
- sd_radv_prefix_unref(p);
- }
-
- while (ra->route_prefixes) {
- sd_radv_route_prefix *p = ra->route_prefixes;
-
- LIST_REMOVE(prefix, ra->route_prefixes, p);
- sd_radv_route_prefix_unref(p);
- }
+ LIST_CLEAR(prefix, ra->prefixes, sd_radv_prefix_unref);
+ LIST_CLEAR(prefix, ra->route_prefixes, sd_radv_route_prefix_unref);
free(ra->rdnss);
free(ra->dnssl);
static int peer_resolve_endpoint(WireguardPeer *peer);
static void wireguard_peer_clear_ipmasks(WireguardPeer *peer) {
- WireguardIPmask *mask;
-
assert(peer);
- while ((mask = peer->ipmasks)) {
- LIST_REMOVE(ipmasks, peer->ipmasks, mask);
- free(mask);
- }
+ LIST_CLEAR(ipmasks, peer->ipmasks, free);
}
static WireguardPeer* wireguard_peer_free(WireguardPeer *peer) {
}
void expose_port_free_all(ExposePort *p) {
-
- while (p) {
- ExposePort *q = p;
- LIST_REMOVE(ports, p, q);
- free(q);
- }
+ LIST_CLEAR(ports, p, free);
}
int expose_port_flush(FirewallContext **fw_ctx, ExposePort* l, int af, union in_addr_union *exposed) {
} AsyncPolkitQuery;
static AsyncPolkitQuery *async_polkit_query_free(AsyncPolkitQuery *q) {
- AsyncPolkitQueryAction *a;
-
if (!q)
return NULL;
sd_event_source_disable_unref(q->defer_event_source);
- while ((a = LIST_POP(authorized, q->authorized_actions)))
- async_polkit_query_action_free(a);
+ LIST_CLEAR(authorized, q->authorized_actions, async_polkit_query_action_free);
async_polkit_query_action_free(q->denied_action);
async_polkit_query_action_free(q->error_action);
}
void open_file_free_many(OpenFile **head) {
- OpenFile *of;
-
- while ((of = *head)) {
- LIST_REMOVE(open_files, *head, of);
- of = open_file_free(of);
- }
+ LIST_CLEAR(open_files, *head, open_file_free);
}
static const char * const open_file_flags_table[_OPENFILE_MAX] = {
v->pushed_fds = mfree(v->pushed_fds);
v->n_pushed_fds = 0;
- while (v->output_queue) {
- VarlinkJsonQueueItem *q = v->output_queue;
-
- LIST_REMOVE(queue, v->output_queue, q);
- varlink_json_queue_item_free(q);
- }
+ LIST_CLEAR(queue, v->output_queue, varlink_json_queue_item_free);
v->output_queue_tail = NULL;
v->event = sd_event_unref(v->event);
} UnitStatusInfo;
static void unit_status_info_free(UnitStatusInfo *info) {
- ExecStatusInfo *p;
- UnitCondition *c;
-
strv_free(info->documentation);
strv_free(info->dropin_paths);
strv_free(info->triggered_by);
strv_free(info->triggers);
strv_free(info->listen);
- while ((c = info->conditions)) {
- LIST_REMOVE(conditions, info->conditions, c);
- unit_condition_free(c);
- }
-
- while ((p = info->exec_status_info_list)) {
- LIST_REMOVE(exec_status_info_list, info->exec_status_info_list, p);
- exec_status_info_free(p);
- }
+ LIST_CLEAR(conditions, info->conditions, unit_condition_free);
+ LIST_CLEAR(exec_status_info_list, info->exec_status_info_list, exec_status_info_free);
}
static void format_active_state(const char *active_state, const char **active_on, const char **active_off) {
};
static PatternElement *pattern_element_free_all(PatternElement *e) {
- PatternElement *p;
-
- while ((p = LIST_POP(elements, e)))
- free(p);
+ LIST_CLEAR(elements, e, free);
return NULL;
}
DEFINE_TRIVIAL_CLEANUP_FUNC(UnitStatusInfo*, unit_status_info_free);
static void context_clear(Context *c) {
- UnitStatusInfo *p;
-
assert(c);
free(c->zone);
sd_bus_slot_unref(c->slot_job_removed);
- while ((p = c->units)) {
- LIST_REMOVE(units, c->units, p);
- unit_status_info_free(p);
- }
+ LIST_CLEAR(units, c->units, unit_status_info_free);
}
static int context_add_ntp_service(Context *c, const char *s, const char *source) {