Merge pull request #217 from lebrush/rime-memory

Use memcpy, memcmp functions for the rime cmp and cpy
This commit is contained in:
Oliver Schmidt 2013-05-21 02:46:13 -07:00
commit dd6f1c4824

View file

@ -43,6 +43,7 @@
*/ */
#include "net/rime/rimeaddr.h" #include "net/rime/rimeaddr.h"
#include <string.h>
rimeaddr_t rimeaddr_node_addr; rimeaddr_t rimeaddr_node_addr;
#if RIMEADDR_SIZE == 2 #if RIMEADDR_SIZE == 2
@ -58,22 +59,13 @@ const rimeaddr_t rimeaddr_null = { { 0, 0, 0, 0, 0, 0, 0, 0 } };
void void
rimeaddr_copy(rimeaddr_t *dest, const rimeaddr_t *src) rimeaddr_copy(rimeaddr_t *dest, const rimeaddr_t *src)
{ {
uint8_t i; memcpy(dest, src, RIMEADDR_SIZE);
for(i = 0; i < RIMEADDR_SIZE; i++) {
dest->u8[i] = src->u8[i];
}
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int int
rimeaddr_cmp(const rimeaddr_t *addr1, const rimeaddr_t *addr2) rimeaddr_cmp(const rimeaddr_t *addr1, const rimeaddr_t *addr2)
{ {
uint8_t i; return (memcmp(addr1, addr2, RIMEADDR_SIZE) == 0);
for(i = 0; i < RIMEADDR_SIZE; i++) {
if(addr1->u8[i] != addr2->u8[i]) {
return 0;
}
}
return 1;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void void