Add uc_mbuf_head accessor function
This commit is contained in:
+10
-1
@@ -151,7 +151,7 @@ static UC_INLINE uint32_t uc_mbuf_tailroom(struct MBuf *mbuf)
|
||||
/**
|
||||
* @return the length of the headroom in this mbuf
|
||||
*/
|
||||
static inline uint32_t uc_mbuf_headroom(struct MBuf *mbuf)
|
||||
static UC_INLINE uint32_t uc_mbuf_headroom(struct MBuf *mbuf)
|
||||
{
|
||||
return (uint32_t)(mbuf->head - mbuf->bufstart);
|
||||
}
|
||||
@@ -187,6 +187,15 @@ uint8_t *uc_mbuf_push(struct MBuf *mbuf, uint32_t size);
|
||||
**/
|
||||
uint8_t *uc_mbuf_pull(struct MBuf *mbuf, uint32_t size);
|
||||
|
||||
/** Get a pointer to the data of the buffer
|
||||
*
|
||||
* @return pointer to the start of the data (head)
|
||||
*/
|
||||
static UC_INLINE uint8_t *uc_mbuf_head(struct MBuf* mbuf)
|
||||
{
|
||||
return mbuf->head;
|
||||
}
|
||||
|
||||
#undef UC_INLINE
|
||||
|
||||
#endif
|
||||
|
||||
+2
-2
@@ -191,7 +191,7 @@ START_TEST (test_mbuf_copy)
|
||||
fail_if(copy == NULL);
|
||||
fail_if(uc_mbuf_len(copy) != 10);
|
||||
fail_if(uc_mbuf_headroom(copy) != 5);
|
||||
fail_if(memcmp(mbuf->head, copy->head, 10) != 0);
|
||||
fail_if(memcmp(uc_mbuf_head(mbuf), uc_mbuf_head(copy), 10) != 0);
|
||||
|
||||
uc_mbuf_free(mbuf);
|
||||
uc_mbuf_free(copy);
|
||||
@@ -211,7 +211,7 @@ START_TEST (test_mbuf_zero)
|
||||
strcpy((char*)data1, "123456789");
|
||||
uc_mbuf_zero(mbuf);
|
||||
|
||||
fail_if(memcmp(mbuf->head, "\0\0\0\0\0\0\0\0\0\0", 10) != 0);
|
||||
fail_if(memcmp(uc_mbuf_head(mbuf), "\0\0\0\0\0\0\0\0\0\0", 10) != 0);
|
||||
|
||||
uc_mbuf_free(mbuf);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user