feature: kmalloc kfree and krealloc are good

This commit is contained in:
2024-09-21 12:17:27 +02:00
parent 0467c45bf0
commit 943f2beab9
15 changed files with 607 additions and 23 deletions

View 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;
}

View 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;
}