* Change type of the queue entry. * Possibly reallocates it from another UMA zone. */
| 3047 | * Possibly reallocates it from another UMA zone. |
| 3048 | */ |
| 3049 | static __inline item_p |
| 3050 | ng_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 |
no test coverage detected