net: buf: Add net_buf_simple_clone
Provides a way to clone a net_buf_simple without altering the state of the original buffer. The primary usage scenario is for manipulating a previously allocated PDU inside a buffer without altering the length and offset of the buffer. Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
This commit is contained in:
parent
9fdefc7d73
commit
3d201b45f9
2 changed files with 19 additions and 0 deletions
|
@ -153,6 +153,19 @@ static inline void net_buf_simple_reset(struct net_buf_simple *buf)
|
|||
buf->data = buf->__buf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone buffer state, using the same data buffer.
|
||||
*
|
||||
* Initializes a buffer to point to the same data as an existing buffer.
|
||||
* Allows operations on the same data without altering the length and
|
||||
* offset of the original.
|
||||
*
|
||||
* @param original Buffer to clone.
|
||||
* @param clone The new clone.
|
||||
*/
|
||||
void net_buf_simple_clone(const struct net_buf_simple *original,
|
||||
struct net_buf_simple *clone);
|
||||
|
||||
/**
|
||||
* @brief Prepare data to be added at the end of the buffer
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue