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

Function ng_realloc_item

freebsd/netgraph/ng_base.c:3049–3074  ·  view source on GitHub ↗

* Change type of the queue entry. * Possibly reallocates it from another UMA zone. */

Source from the content-addressed store, hash-verified

3047 * Possibly reallocates it from another UMA zone.
3048 */
3049static __inline item_p
3050ng_realloc_item(item_p pitem, int type, int flags)
3051{
3052 item_p item;
3053 int from, to;
3054
3055 KASSERT((pitem != NULL), ("%s: can't reallocate NULL", __func__));
3056 KASSERT(((type & ~NGQF_TYPE) == 0),
3057 ("%s: incorrect item type: %d", __func__, type));
3058
3059 from = ((pitem->el_flags & NGQF_TYPE) == NGQF_DATA);
3060 to = (type == NGQF_DATA);
3061 if (from != to) {
3062 /* If reallocation is required do it and copy item. */
3063 if ((item = ng_alloc_item(type, flags)) == NULL) {
3064 ng_free_item(pitem);
3065 return (NULL);
3066 }
3067 *item = *pitem;
3068 ng_free_item(pitem);
3069 } else
3070 item = pitem;
3071 item->el_flags = (item->el_flags & ~NGQF_TYPE) | type;
3072
3073 return (item);
3074}
3075
3076/************************************************************************
3077 Module routines

Callers 1

ng_send_fn2Function · 0.70

Calls 2

ng_alloc_itemFunction · 0.70
ng_free_itemFunction · 0.70

Tested by

no test coverage detected