Skip to content

Commit 329b68c

Browse files
committed
include:circbuf: Add peek data api
Signed-off-by: Ajay Bhargav <[email protected]>
1 parent 5af4f65 commit 329b68c

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

include/circbuf.h

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,30 @@ int circbuf_pop_byte(int handle, unsigned char *data);
5454
* @param handle [in] Handle to circular buffer
5555
* @param data [out] pointer to read buffer
5656
* @param len [in] Length of data to read
57-
* @return On success, returns actual length read, -1 on error
57+
* @return On success, returns actual length read, negative value on error
5858
*/
5959
int circbuf_pop(int handle, unsigned char *data, unsigned int len);
6060

61+
/**
62+
* Peek a byte from head of circular buffer. Subsequent calls
63+
* to this function will lead to same byte unless @ref circbuf_pop or
64+
* @ref circbuf_pop_byte is called.
65+
* @param handle [in] Handle to circular buffer
66+
* @param data [out] Pointer to read buffer
67+
* @return On success, returns actual length read, negative value on error
68+
*/
69+
int circbuf_peek_byte(int handle, unsigned char *data);
70+
71+
/**
72+
* Peek data from start of circular buffer. Data will not be removed
73+
* from buffer unless @ref circbuf_pop or @ref circbuf_pop_byte is called.
74+
* @param handle [in] Handle to circular buffer
75+
* @param data [out] pointer to read buffer
76+
* @param len [in] Length of data to read
77+
* @return On success, returns actual length read, negative value on error
78+
*/
79+
int circbuf_peek(int handle, unsigned char *data, int len);
80+
6181
/**
6282
* Check if buffer is empty
6383
* @param handle [in] Handle to circular buffer

0 commit comments

Comments
 (0)