Ejemplo n.º 1
0
Condition* condition_free_list(Condition *first) {
        Condition *c, *n;

        LIST_FOREACH_SAFE(conditions, c, n, first)
                condition_free(c);

        return NULL;
}
static void link_configs_free(link_config_ctx *ctx) {
        link_config *link, *link_next;

        if (!ctx)
                return;

        LIST_FOREACH_SAFE(links, link, link_next, ctx->links)
                link_config_free(link);
}
Ejemplo n.º 3
0
void
osd_deregister(u_int type, u_int slot)
{
	struct osd *osd, *tosd;

	KASSERT(type >= OSD_FIRST && type <= OSD_LAST, ("Invalid type."));
	KASSERT(slot > 0, ("Invalid slot."));
	KASSERT(osd_destructors[type][slot - 1] != NULL, ("Unused slot."));

	sx_xlock(&osd_module_lock[type]);
	rm_wlock(&osd_object_lock[type]);
	/*
	 * Free all OSD for the given slot.
	 */
	mtx_lock(&osd_list_lock[type]);
	LIST_FOREACH_SAFE(osd, &osd_list[type], osd_next, tosd)
		do_osd_del(type, osd, slot, 1);
	mtx_unlock(&osd_list_lock[type]);
	/*
	 * Set destructor to NULL to free the slot.
	 */
	osd_destructors[type][slot - 1] = NULL;
	if (slot == osd_nslots[type]) {
		osd_nslots[type]--;
		osd_destructors[type] = realloc(osd_destructors[type],
		    sizeof(osd_destructor_t) * osd_nslots[type], M_OSD,
		    M_NOWAIT | M_ZERO);
		if (osd_nmethods[type] != 0)
			osd_methods[type] = realloc(osd_methods[type],
			    sizeof(osd_method_t) * osd_nslots[type] *
			    osd_nmethods[type], M_OSD, M_NOWAIT | M_ZERO);
		/*
		 * We always reallocate to smaller size, so we assume it will
		 * always succeed.
		 */
		KASSERT(osd_destructors[type] != NULL &&
		    (osd_nmethods[type] == 0 || osd_methods[type] != NULL),
		    ("realloc() failed"));
		OSD_DEBUG("Deregistration of the last slot (type=%u, slot=%u).",
		    type, slot);
	} else {
		OSD_DEBUG("Slot deregistration (type=%u, slot=%u).",
		    type, slot);
	}
	rm_wunlock(&osd_object_lock[type]);
	sx_xunlock(&osd_module_lock[type]);
}
Ejemplo n.º 4
0
void cgroup_bonding_free_list(CGroupBonding *first, bool remove_or_trim) {
        CGroupBonding *b, *n;

        LIST_FOREACH_SAFE(by_unit, b, n, first)
                cgroup_bonding_free(b, remove_or_trim);
}
Ejemplo n.º 5
0
void condition_free_list(Condition *first) {
        Condition *c, *n;

        LIST_FOREACH_SAFE(conditions, c, n, first)
                condition_free(c);
}