void manager_free(Manager *m) { Machine *machine; Image *i; assert(m); while ((machine = hashmap_first(m->machines))) machine_free(machine); hashmap_free(m->machines); hashmap_free(m->machine_units); hashmap_free(m->machine_leaders); while ((i = hashmap_steal_first(m->image_cache))) image_unref(i); hashmap_free(m->image_cache); sd_event_source_unref(m->image_cache_defer_event); bus_verify_polkit_async_registry_free(m->polkit_registry); sd_bus_unref(m->bus); sd_event_unref(m->event); free(m); }
CurlGlue *curl_glue_unref(CurlGlue *g) { sd_event_source *io; if (!g) return NULL; if (g->curl) curl_multi_cleanup(g->curl); while ((io = hashmap_steal_first(g->ios))) { int fd; fd = sd_event_source_get_io_fd(io); assert(fd >= 0); hashmap_remove(g->translate_fds, FD_TO_PTR(fd)); safe_close(fd); sd_event_source_unref(io); } hashmap_free(g->ios); sd_event_source_unref(g->timer); sd_event_unref(g->event); free(g); return NULL; }
static void vacuum_candidate_hasmap_free(Hashmap *h) { struct vacuum_candidate *c; while ((c = hashmap_steal_first(h))) vacuum_candidate_free(c); hashmap_free(h); }
void bus_verify_polkit_async_registry_free(Hashmap *registry) { #ifdef ENABLE_POLKIT AsyncPolkitQuery *q; while ((q = hashmap_steal_first(registry))) async_polkit_query_free(q); hashmap_free(registry); #endif }
void dns_trust_anchor_flush(DnsTrustAnchor *d) { DnsAnswer *a; assert(d); while ((a = hashmap_steal_first(d->by_key))) dns_answer_unref(a); d->by_key = hashmap_free(d->by_key); }
static int image_flush_cache(sd_event_source *s, void *userdata) { Manager *m = userdata; Image *i; assert(s); assert(m); while ((i = hashmap_steal_first(m->image_cache))) image_unref(i); return 0; }
static void free_arg_disks(void) { crypto_device *d; while ((d = hashmap_steal_first(arg_disks))) { free(d->uuid); free(d->keyfile); free(d->name); free(d->options); free(d); } hashmap_free(arg_disks); }
void manager_etc_hosts_flush(Manager *m) { EtcHostsItem *item; EtcHostsItemByName *bn; while ((item = set_steal_first(m->etc_hosts_by_address))) { strv_free(item->names); free(item); } while ((bn = hashmap_steal_first(m->etc_hosts_by_name))) { free(bn->name); free(bn->items); free(bn); } m->etc_hosts_by_address = set_free(m->etc_hosts_by_address); m->etc_hosts_by_name = hashmap_free(m->etc_hosts_by_name); m->etc_hosts_mtime = USEC_INFINITY; }
static void group_hashmap_clear(Hashmap *h) { Group *g; while ((g = hashmap_steal_first(h))) group_free(g); }
void *set_steal_first(Set *s) { return hashmap_steal_first(MAKE_HASHMAP(s)); }