Compare commits

..

No commits in common. "6c6f7eb902134c851bcb84edd3d8b6a7dc93dae4" and "2f31564ce2ea9c68df3b7ce49257273cbb3446c6" have entirely different histories.

3 changed files with 2 additions and 72 deletions

View file

@ -6,7 +6,7 @@ u32 axl_strlen(const i8* s)
{
return 0;
}
u32 len = 0;
while(s[len] != '\0')
@ -52,70 +52,3 @@ i8* axl_strncpy(i8* dst, const i8* src, u32 n)
return dst;
}
i8* axl_strcat(i8* dst, const i8* src)
{
if(dst == NULL || src == NULL)
{
return dst;
}
return axl_strcpy(dst + axl_strlen(dst), src);
}
i8* axl_strncat(i8* dst, const i8* src, u32 n) //n actually means "not more than"
{
if(!dst || !src)
{
return dst;
}
i8* p = dst + axl_strlen(dst);
while (n-- && (*p++ = *src++)); //quick note: '\0' == 0
*p = '\0'; //in case we copied exactly n without '\0'
return dst;
}
i32 axl_strcmp(const i8* s1, const i8* s2)
{
if (!s1 || !s2)
{
return (s1 == s2) ? 0 : (!s1 ? -1 : 1);
}
for (;; s1++, s2++)
{
u8 c1 = *(const u8*)s1;
u8 c2 = *(const u8*)s2;
if (c1 != c2 || c1 == '\0' || c2 == '\0')
{
return c1 - c2;
}
}
return 0;
}
i32 axl_strncmp(const i8* s1, const i8* s2, u32 n)
{
if (!s1 || !s2)
{
return (s1 == s2) ? 0 : (!s1 ? -1 : 1);
}
for (u32 i = 0; i < n; s1++, s2++)
{
u8 c1 = *(const u8*)s1;
u8 c2 = *(const u8*)s2;
if (c1 != c2 || c1 == '\0' || c2 == '\0')
{
return c1 - c2;
}
}
return 0;
}

View file

@ -6,8 +6,5 @@
u32 axl_strlen(const i8* s);
i8* axl_strcpy(i8* dst, const i8* src);
i8* axl_strncpy(i8* dst, const i8* src, u32 n);
i8* axl_strcat(i8* dst, const i8* src);
i8* axl_strncat(i8* dst, const i8* src, u32 n);
i32 axl_strcmp(const i8* s1, const i8* s2);
#endif // AXL_STRING

View file

@ -2,7 +2,7 @@ CC = clang
CFLAGS = -Wall -Wextra -Werror -pedantic -std=c11 -nostdlib -static -Oz -ffreestanding
LDFLAGS = -Wl,/SUBSYSTEM:CONSOLE,/ENTRY:_start -fuse-ld=lld
LIBS = -lkernel32
SOURCES = $(wildcard *.c)
SOURCES = main.c axl_memory.c
TARGET = prog.exe
all: clean $(TARGET)