feature: kmalloc kfree and krealloc are good
This commit is contained in:
21
libbozo/src/string/memmove.c
Normal file
21
libbozo/src/string/memmove.c
Normal file
@ -0,0 +1,21 @@
|
||||
#include <stddef.h>
|
||||
|
||||
void *memmove(void *dest, const void *src, size_t n)
|
||||
{
|
||||
size_t i = 0;
|
||||
const char *cast1 = (const char *)src;
|
||||
char *cast2 = (char *)dest;
|
||||
|
||||
if (!cast1 && !cast2 && n > 0)
|
||||
return (0);
|
||||
if (&cast1[0] > &cast2[0]) {
|
||||
while (i < n) {
|
||||
cast2[i] = cast1[i];
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
while (n--)
|
||||
cast2[n] = cast1[n];
|
||||
}
|
||||
return cast2;
|
||||
}
|
12
libbozo/src/string/strcpy.c
Normal file
12
libbozo/src/string/strcpy.c
Normal file
@ -0,0 +1,12 @@
|
||||
#include <stddef.h>
|
||||
|
||||
char *strcpy(char *dest, const char *src)
|
||||
{
|
||||
size_t i = 0;
|
||||
if (!src)
|
||||
return NULL;
|
||||
for (; src[i]; i++)
|
||||
dest[i] = src[i];
|
||||
dest[i] = '\0';
|
||||
return dest;
|
||||
}
|
Reference in New Issue
Block a user