MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ng_free_item

Function ng_free_item

freebsd/netgraph/ng_base.c:3004–3043  ·  view source on GitHub ↗

* Release a queue entry */

Source from the content-addressed store, hash-verified

3002 * Release a queue entry
3003 */
3004void
3005ng_free_item(item_p item)
3006{
3007 /*
3008 * The item may hold resources on its own. We need to free
3009 * these before we can free the item. What they are depends upon
3010 * what kind of item it is. it is important that nodes zero
3011 * out pointers to resources that they remove from the item
3012 * or we release them again here.
3013 */
3014 switch (item->el_flags & NGQF_TYPE) {
3015 case NGQF_DATA:
3016 /* If we have an mbuf still attached.. */
3017 NG_FREE_M(_NGI_M(item));
3018 break;
3019 case NGQF_MESG:
3020 _NGI_RETADDR(item) = 0;
3021 NG_FREE_MSG(_NGI_MSG(item));
3022 break;
3023 case NGQF_FN:
3024 case NGQF_FN2:
3025 /* nothing to free really, */
3026 _NGI_FN(item) = NULL;
3027 _NGI_ARG1(item) = NULL;
3028 _NGI_ARG2(item) = 0;
3029 break;
3030 }
3031 /* If we still have a node or hook referenced... */
3032 _NGI_CLR_NODE(item);
3033 _NGI_CLR_HOOK(item);
3034
3035#ifdef NETGRAPH_DEBUG
3036 mtx_lock(&ngq_mtx);
3037 TAILQ_REMOVE(&ng_itemlist, item, all);
3038 allocated--;
3039 mtx_unlock(&ngq_mtx);
3040#endif
3041 uma_zfree(((item->el_flags & NGQF_TYPE) == NGQF_DATA) ?
3042 ng_qdzone : ng_qzone, item);
3043}
3044
3045/*
3046 * Change type of the queue entry.

Callers 1

ng_realloc_itemFunction · 0.70

Calls 3

mtx_lockFunction · 0.50
mtx_unlockFunction · 0.50
uma_zfreeFunction · 0.50

Tested by

no test coverage detected