Compare commits

...

4 commits

Author SHA1 Message Date
ccec181771 Handle NULLs 2025-11-27 21:14:48 +03:00
6942e962e2 axl_strncpy 2025-11-27 21:10:44 +03:00
e7e337c873 axl_strcpy 2025-11-27 20:58:48 +03:00
32f1b61324 axl_strlen 2025-11-27 20:51:48 +03:00
2 changed files with 64 additions and 0 deletions

54
axl_string.cpp Normal file
View file

@ -0,0 +1,54 @@
#include "axl_string.h"
u32 axl_strlen(const i8* s)
{
if(s == NULL)
{
return 0;
}
u32 len = 0;
while(s[len] != '\0')
{
len++;
}
return len;
}
i8* axl_strcpy(i8* dst, const i8* src)
{
if(dst == NULL || src == NULL)
{
return dst;
}
i8* start = dst;
while((*(dst++) = *(src++)) != '\0');
return start;
}
i8* axl_strncpy(i8* dst, const i8* src, u32 n)
{
if(dst == NULL || src == NULL)
{
return dst;
}
u32 i = 0;
for(; i < n && src[i] != '\0'; i++)
{
dst[i] = src[i];
}
for(; i < n; i++)
{
dst[i] = '\0';
}
return dst;
}

10
axl_string.h Normal file
View file

@ -0,0 +1,10 @@
#ifndef AXL_STRING_H
#define AXL_STRING_H
#include "axl_types.h"
u32 axl_strlen(const i8* s);
i8* axl_strcpy(i8* dst, const i8* src);
i8* axl_strncpy(i8* dst, const i8* src, u32 n);
#endif // AXL_STRING