Renamed function for compacting the data in the rimebuf: rimebuf_compact

This commit is contained in:
adamdunkels 2007-03-14 00:30:11 +00:00
parent 91f8c4b8e4
commit 674f373f76
2 changed files with 19 additions and 9 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: rimebuf.c,v 1.2 2007/03/13 10:28:16 adamdunkels Exp $ * $Id: rimebuf.c,v 1.3 2007/03/14 00:30:11 adamdunkels Exp $
*/ */
/** /**
@ -76,11 +76,15 @@ rimebuf_copyfrom(u8_t *from, u16_t len)
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void void
rimebuf_copy_reference(void) rimebuf_compact(void)
{ {
if(rimebuf_is_reference()) { if(rimebuf_is_reference()) {
memcpy(&rimebuf[RIMEBUF_HDR_SIZE], rimebuf_reference_ptr(), memcpy(&rimebuf[RIMEBUF_HDR_SIZE], rimebuf_reference_ptr(),
rimebuf_datalen()); rimebuf_datalen());
} else {
memcpy(&rimebuf[RIMEBUF_HDR_SIZE], &rimebuf[bufptr + RIMEBUF_HDR_SIZE],
rimebuf_datalen());
bufptr = 0;
} }
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/

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: rimebuf.h,v 1.2 2007/03/13 10:27:36 adamdunkels Exp $ * $Id: rimebuf.h,v 1.3 2007/03/14 00:30:11 adamdunkels Exp $
*/ */
/** /**
@ -51,7 +51,7 @@
/** /**
* \brief The size of the rimebuf header, in bytes * \brief The size of the rimebuf header, in bytes
*/ */
#define RIMEBUF_HDR_SIZE 16 #define RIMEBUF_HDR_SIZE 32
/** /**
* \brief Clear and reset the rimebuf * \brief Clear and reset the rimebuf
@ -177,14 +177,20 @@ int rimebuf_is_reference(void);
void *rimebuf_reference_ptr(void); void *rimebuf_reference_ptr(void);
/** /**
* \brief Copy referenced data from the external location into the rimebuf * \brief Compact the rimebuf
* *
* This function copies external data that has previously * This function compacts the rimebuf by copying the data
* been referenced with rimebuf_reference() into the * portion of the rimebuf so that becomes consecutive to
* rimebuf. * the header. It also copies external data that has
* previously been referenced with rimebuf_reference()
* into the rimebuf.
*
* This function is called by the Rime code before a
* packet is to be sent by a device driver. This assures
* that the entire packet is consecutive in memory.
* *
*/ */
void rimebuf_copy_reference(void); void rimebuf_compact(void);
/** /**
* \brief Copy from external data into the rimebuf * \brief Copy from external data into the rimebuf