Compare commits
4 commits
574edcd4c5
...
ccec181771
| Author | SHA1 | Date | |
|---|---|---|---|
| ccec181771 | |||
| 6942e962e2 | |||
| e7e337c873 | |||
| 32f1b61324 |
2 changed files with 64 additions and 0 deletions
54
axl_string.cpp
Normal file
54
axl_string.cpp
Normal 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
10
axl_string.h
Normal 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
|
||||
Loading…
Reference in a new issue