feat: ensemble de fonctions permettant la gestion de la mémoire

This commit is contained in:
Nicolas Hordé 2007-04-02 13:03:33 +00:00
parent dbbbc1458e
commit 7b41bd6595
1 changed files with 38 additions and 0 deletions

38
lib/memory.c Normal file
View File

@ -0,0 +1,38 @@
#include "types.h"
void memset(void *dest, u8 val, u16 count, u32 size)
{
char *temp;
for(temp = (u8 *)dest; count != 0; count--)
{
*temp = val;
temp+=size;
}
}
void memcpy(void *dest, const void *src, u32 size)
{
u8 *s, *d;
u32 i;
s = (u8 *) src;
d = (u8 *) dest;
for(i=0;i<size;i++){
*(d+i) = *(s+i);
}
}
int memcmp(const void *src, const void *dest, int count)
{
const unsigned char *mem1 = (const unsigned char *)src;
const unsigned char *mem2 = (const unsigned char *)dest;
for(; count != 0; count--)
{
if(*mem1 != *mem2)
return *mem1 - *mem2;
mem1++;
mem2++;
}
}