/* This file is in the public domain. */ #include #include "structs.h" #include "listen.h" void listen_ref(LISTEN *l) { l->refs ++; if (l->refs < 1) abort(); } void listen_deref(LISTEN *l) { LEP *lep; MAP *map; l->refs --; if (l->refs > 0) return; if (l->refs < 0) abort(); while (l->endpoints) { lep = l->endpoints; l->endpoints = lep->link; (*lep->ops->free)(lep->priv); free(lep); } while (l->mappings) { map = l->mappings; l->mappings = map->link; (*map->ops->free)(map->priv); free(map); } free(l); } void listen_deref_chain(LISTEN *chain) { LISTEN *l; while (chain) { l = chain; chain = l->link; listen_deref(l); } }