Added functions for accessing the data and length of a queued buffer

This commit is contained in:
adamdunkels 2007-03-20 12:26:23 +00:00
parent a43c213ff2
commit 516f9316ab
2 changed files with 26 additions and 2 deletions

View file

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: queuebuf.c,v 1.3 2007/03/15 09:56:39 adamdunkels Exp $ * $Id: queuebuf.c,v 1.4 2007/03/20 12:26:23 adamdunkels Exp $
*/ */
/** /**
@ -116,3 +116,23 @@ queuebuf_to_rimebuf(struct queuebuf *b)
} }
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void *
queuebuf_dataptr(struct queuebuf *b)
{
struct queuebuf_ref *r;
if(memb_inmemb(&bufmem, b)) {
return b->data;
} else if(memb_inmemb(&refbufmem, b)) {
r = (struct queuebuf_ref *)b;
return r->ref;
}
return NULL;
}
/*---------------------------------------------------------------------------*/
int
queuebuf_datalen(struct queuebuf *b)
{
return b->len;
}
/*---------------------------------------------------------------------------*/

View file

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: queuebuf.h,v 1.1 2007/02/28 16:38:51 adamdunkels Exp $ * $Id: queuebuf.h,v 1.2 2007/03/20 12:26:23 adamdunkels Exp $
*/ */
/** /**
@ -52,4 +52,8 @@ void queuebuf_free(struct queuebuf *b);
void queuebuf_from_rimebuf(struct queuebuf *b); void queuebuf_from_rimebuf(struct queuebuf *b);
void queuebuf_to_rimebuf(struct queuebuf *b); void queuebuf_to_rimebuf(struct queuebuf *b);
void *queuebuf_dataptr(struct queuebuf *b);
int queuebuf_datalen(struct queuebuf *b);
#endif /* __QUEUEBUF_H__ */ #endif /* __QUEUEBUF_H__ */