static void free_connections(struct ev_loop *loop) { struct cork_dllist_item *curr; for (curr = cork_dllist_start(&connections); !cork_dllist_is_end(&connections, curr); curr = curr->next) { struct server *server = cork_container_of(curr, struct server, entries); struct remote *remote = server->remote; close_and_free_server(loop, server); close_and_free_remote(loop, remote); } }
void cork_dllist_map(struct cork_dllist *list, cork_dllist_map_func func, void *user_data) { struct cork_dllist_item *curr = cork_dllist_start(list); while (!cork_dllist_is_end(list, curr)) { /* Extract the next pointer now, just in case func frees the * list item. */ struct cork_dllist_item *next = curr->next; func(curr, user_data); curr = next; } }