nRF5 SDK v16.0.0
Data Structures | Typedefs | Functions
Memory management for socket

Memory management for socket. More...

Data Structures

struct  mbuf_t
 Memory management structure. More...
 

Typedefs

typedef uint32_t(* mbuf_read_fn )(void *p_ctx, uint32_t read_offset, uint8_t *p_dest, uint32_t dest_len)
 Function for reading data from a buffer.
 
typedef uint32_t(* mbuf_buf_len_fn )(void *p_ctx)
 Function for checking buffer length.
 
typedef void(* mbuf_free_fn )(void *p_ctx)
 Function for freeing a buffer.
 

Functions

uint32_t mbuf_init (mbuf_t *p_mbuf, mbuf_read_fn read_fn, mbuf_buf_len_fn buf_len_fn, mbuf_free_fn free_fn, uint32_t nmemb)
 Function for initializing the memory buffer manager. More...
 
void mbuf_deinit (mbuf_t *p_mbuf)
 Function for deinitializing the memory buffer manager. More...
 
uint32_t mbuf_write (mbuf_t *p_mbuf, void *p_ctx)
 Function for putting a data buffer in the mbuf. More...
 
uint32_t mbuf_read (mbuf_t *p_mbuf, void *p_buf, uint32_t buf_size)
 Function for reading data from the mbuf. More...
 
bool mbuf_empty (mbuf_t *p_mbuf)
 Function for checking if the mbuf is empty. More...
 

Detailed Description

Memory management for socket.

Function Documentation

void mbuf_deinit ( mbuf_t p_mbuf)

Function for deinitializing the memory buffer manager.

This function releases any resources allocated for mbuf instance pointed by p_mbuf.

Parameters
[in,out]p_mbufPointer to the mbuf structure to deinitialize.
bool mbuf_empty ( mbuf_t p_mbuf)

Function for checking if the mbuf is empty.

Parameters
[in]p_mbufPointer to the mbuf structure that shall be checked.
Returns
True if mbuf is empty, false otherwise.
uint32_t mbuf_init ( mbuf_t p_mbuf,
mbuf_read_fn  read_fn,
mbuf_buf_len_fn  buf_len_fn,
mbuf_free_fn  free_fn,
uint32_t  nmemb 
)

Function for initializing the memory buffer manager.

This function allocates resources for the mbuf FIFO and initializes the mbuf.

Parameters
[in,out]p_mbufPointer to the mbuf structure to initialize.
[in]read_fnFunction for reading data from a buffer.
[in]buf_len_fnFunction for checking buffer length.
[in]free_fnFunction for freeing a buffer.
[in]nmembMaximum number of data buffers.
Returns
NRF_SUCCESS on success, otherwise error code is returned.
uint32_t mbuf_read ( mbuf_t p_mbuf,
void *  p_buf,
uint32_t  buf_size 
)

Function for reading data from the mbuf.

Parameters
[in,out]p_mbufPointer to the mbuf structure to read data from.
[in]p_bufPointer to the buffer where data shall be read from.
[out]buf_sizeSize of the buffer pointed by p_buf.
Returns
NRF_SUCCESS on success, otherwise error code is returned.
uint32_t mbuf_write ( mbuf_t p_mbuf,
void *  p_ctx 
)

Function for putting a data buffer in the mbuf.

Parameters
[in,out]p_mbufPointer to the mbuf structure that shall store the buffer.
[in]p_ctxPointer to the data buffer to store.
Returns
NRF_SUCCESS on success, otherwise error code is returned.

Documentation feedback | Developer Zone | Subscribe | Updated