feat: initial version

This commit is contained in:
Zoëy Noort 2025-05-05 18:24:21 +02:00
parent 5cad2db883
commit 6428ed06b0
16 changed files with 263 additions and 0 deletions

38
srcs/ft_memset64.c Normal file
View file

@ -0,0 +1,38 @@
#include <stddef.h>
#include <stdint.h>
void *ft_memset64(void *s, int c, size_t n)
{
unsigned char *ptr = (unsigned char *)s;
uint64_t pattern;
uint64_t *long_ptr;
unsigned char byte = (unsigned char)c;
while (n > 0 && ((uintptr_t)ptr % 8 != 0))
{
*ptr++ = byte;
n--;
}
if (n >= 8)
{
pattern = byte;
pattern |= pattern << 8;
pattern |= pattern << 16;
pattern |= pattern << 32;
long_ptr = (uint64_t *)ptr;
while (n >= 8)
{
*long_ptr++ = pattern;
n -= 8;
}
ptr = (unsigned char *)long_ptr;
}
while (n--)
*ptr++ = byte;
return s;
}