Add uc_mbuf_head accessor function

This commit is contained in:
Nils O. Selåsdal
2013-11-25 20:52:43 +01:00
parent 3d2e0ce540
commit 306a3d2a90
2 changed files with 12 additions and 3 deletions
+10 -1
View File
@@ -151,7 +151,7 @@ static UC_INLINE uint32_t uc_mbuf_tailroom(struct MBuf *mbuf)
/** /**
* @return the length of the headroom in this 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); 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); 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 #undef UC_INLINE
#endif #endif
+2 -2
View File
@@ -191,7 +191,7 @@ START_TEST (test_mbuf_copy)
fail_if(copy == NULL); fail_if(copy == NULL);
fail_if(uc_mbuf_len(copy) != 10); fail_if(uc_mbuf_len(copy) != 10);
fail_if(uc_mbuf_headroom(copy) != 5); 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(mbuf);
uc_mbuf_free(copy); uc_mbuf_free(copy);
@@ -211,7 +211,7 @@ START_TEST (test_mbuf_zero)
strcpy((char*)data1, "123456789"); strcpy((char*)data1, "123456789");
uc_mbuf_zero(mbuf); 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); uc_mbuf_free(mbuf);