[msgb] Add msgb_reset to reset an existing msgb* to the initial state
The reset is useful if one msgb is supposed to be used over and over again and is avoiding to use msgb_free,msgb_alloc in the application code.
This commit is contained in:
parent
77a838dff7
commit
cbbd49807f
|
@ -51,6 +51,7 @@ extern struct msgb *msgb_alloc(u_int16_t size, const char *name);
|
||||||
extern void msgb_free(struct msgb *m);
|
extern void msgb_free(struct msgb *m);
|
||||||
extern void msgb_enqueue(struct llist_head *queue, struct msgb *msg);
|
extern void msgb_enqueue(struct llist_head *queue, struct msgb *msg);
|
||||||
extern struct msgb *msgb_dequeue(struct llist_head *queue);
|
extern struct msgb *msgb_dequeue(struct llist_head *queue);
|
||||||
|
extern void msgb_reset(struct msgb *m);
|
||||||
|
|
||||||
#define msgb_l2(m) ((void *)(m->l2h))
|
#define msgb_l2(m) ((void *)(m->l2h))
|
||||||
#define msgb_l3(m) ((void *)(m->l3h))
|
#define msgb_l3(m) ((void *)(m->l3h))
|
||||||
|
|
|
@ -74,6 +74,26 @@ struct msgb *msgb_dequeue(struct llist_head *queue)
|
||||||
return llist_entry(lh, struct msgb, list);
|
return llist_entry(lh, struct msgb, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void msgb_reset(struct msgb *msg)
|
||||||
|
{
|
||||||
|
msg->len = 0;
|
||||||
|
msg->len = 0;
|
||||||
|
msg->data = msg->_data;
|
||||||
|
|
||||||
|
msg->head = msg->data;
|
||||||
|
msg->data = msg->data;
|
||||||
|
/* reset tail pointer */
|
||||||
|
msg->tail = msg->data;
|
||||||
|
|
||||||
|
/* reset pointers */
|
||||||
|
msg->bts_link = NULL;
|
||||||
|
msg->trx = NULL;
|
||||||
|
msg->lchan = NULL;
|
||||||
|
msg->l2h = NULL;
|
||||||
|
msg->l3h = NULL;
|
||||||
|
msg->smsh = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static __attribute__((constructor)) void on_dso_load_trau_msgb(void)
|
static __attribute__((constructor)) void on_dso_load_trau_msgb(void)
|
||||||
{
|
{
|
||||||
tall_msgb_ctx = talloc_named_const(tall_bsc_ctx, 1, "msgb");
|
tall_msgb_ctx = talloc_named_const(tall_bsc_ctx, 1, "msgb");
|
||||||
|
|
Loading…
Reference in New Issue