feat: changement radical de syntaxe des fonctions
This commit is contained in:
parent
7d8efe7b08
commit
7045741c5e
38
lib/memory.c
38
lib/memory.c
|
@ -1,38 +1,46 @@
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
void memset(void *dest, u8 val, u16 count, u32 size)
|
/*******************************************************************************/
|
||||||
|
|
||||||
|
/* Copie un octet une ou plusieurs fois en mémoire */
|
||||||
|
void memset(void *dst, u8 val, u32 count,u32 size)
|
||||||
{
|
{
|
||||||
char *temp;
|
u8 *temp;
|
||||||
for(temp = (u8 *)dest; count != 0; count--)
|
for(temp = (u8 *)dst; count != 0; count--)
|
||||||
{
|
{
|
||||||
*temp = val;
|
|
||||||
temp+=size;
|
temp+=size;
|
||||||
|
*temp = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void memcpy(void *dest, const void *src, u32 size)
|
/*******************************************************************************/
|
||||||
|
|
||||||
|
/* Copie une portion de mémoire vers une autre */
|
||||||
|
void memcpy(void *src, void *dst, u32 count, u32 size)
|
||||||
{
|
{
|
||||||
u8 *s, *d;
|
char *s, *d;
|
||||||
u32 i;
|
u32 i;
|
||||||
s = (u8*) src;
|
s = (u8*) src;
|
||||||
d = (u8 *) dest;
|
d = (u8*) dst;
|
||||||
for(i=0;i<size;i++){
|
for(i=0;i<count;i++){
|
||||||
*(d+i) = *(s+i);
|
*(d+i*size) = *(s+i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************/
|
||||||
|
|
||||||
|
/* Compare 2 portions de mémoire */
|
||||||
int memcmp(const void *src, const void *dest, int count)
|
u32 memcmp(void *src, void *dst, u32 count, u32 size)
|
||||||
{
|
{
|
||||||
const unsigned char *mem1 = (const unsigned char *)src;
|
const u8 *mem1 = (const u8 *)src;
|
||||||
const unsigned char *mem2 = (const unsigned char *)dest;
|
const u8 *mem2 = (const u8 *)dst;
|
||||||
for(; count != 0; count--)
|
for(; count != 0; count--)
|
||||||
{
|
{
|
||||||
if(*mem1 != *mem2)
|
if(*mem1 != *mem2)
|
||||||
return *mem1 - *mem2;
|
return *mem1 - *mem2;
|
||||||
mem1++;
|
mem1+=size;
|
||||||
mem2++;
|
mem2+=size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************/
|
||||||
|
|
Loading…
Reference in New Issue