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

Function ng_realloc_item

lib/ff_ng_base.c:3073–3098  ·  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

3071 * Possibly reallocates it from another UMA zone.
3072 */
3073static __inline item_p
3074ng_realloc_item(item_p pitem, int type, int flags)
3075{
3076 item_p item;
3077 int from, to;
3078
3079 KASSERT((pitem != NULL), ("%s: can't reallocate NULL", __func__));
3080 KASSERT(((type & ~NGQF_TYPE) == 0),
3081 ("%s: incorrect item type: %d", __func__, type));
3082
3083 from = ((pitem->el_flags & NGQF_TYPE) == NGQF_DATA);
3084 to = (type == NGQF_DATA);
3085 if (from != to) {
3086 /* If reallocation is required do it and copy item. */
3087 if ((item = ng_alloc_item(type, flags)) == NULL) {
3088 ng_free_item(pitem);
3089 return (NULL);
3090 }
3091 *item = *pitem;
3092 ng_free_item(pitem);
3093 } else
3094 item = pitem;
3095 item->el_flags = (item->el_flags & ~NGQF_TYPE) | type;
3096
3097 return (item);
3098}
3099
3100/************************************************************************
3101 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