Handle NULLs
This commit is contained in:
parent
6942e962e2
commit
ccec181771
1 changed files with 15 additions and 0 deletions
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
u32 axl_strlen(const i8* s)
|
||||
{
|
||||
if(s == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 len = 0;
|
||||
|
||||
while(s[len] != '\0')
|
||||
|
|
@ -14,6 +19,11 @@ u32 axl_strlen(const i8* s)
|
|||
|
||||
i8* axl_strcpy(i8* dst, const i8* src)
|
||||
{
|
||||
if(dst == NULL || src == NULL)
|
||||
{
|
||||
return dst;
|
||||
}
|
||||
|
||||
i8* start = dst;
|
||||
|
||||
while((*(dst++) = *(src++)) != '\0');
|
||||
|
|
@ -23,6 +33,11 @@ i8* axl_strcpy(i8* dst, const i8* src)
|
|||
|
||||
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++)
|
||||
|
|
|
|||
Loading…
Reference in a new issue