From 042e25e19b5fc0cec1d47440c26246c886cf39f6 Mon Sep 17 00:00:00 2001 From: Michal Idziorek Date: Sun, 17 May 2015 20:40:29 +0200 Subject: started big cleanup! --- xxx/lib/string/string.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 xxx/lib/string/string.c (limited to 'xxx/lib/string/string.c') diff --git a/xxx/lib/string/string.c b/xxx/lib/string/string.c new file mode 100644 index 0000000..729c509 --- /dev/null +++ b/xxx/lib/string/string.c @@ -0,0 +1,37 @@ +#include + +//length 0 for null terminated strings; +bool strcmp(char *str1, char *str2, int length) +{ + int i=0; + while(true) + { + if(str1[i]!=str2[i])return false; + i++; + + if(i==length) return true; + if(str1[i]==0||str2[i]==0) + { + if(str1[i]==str2[i])return true; + return false; + } + } + +} + +void* memcpy(void* restrict dstptr, const void* restrict srcptr, int size) +{ + unsigned char* dst = (unsigned char*) dstptr; + const unsigned char* src = (const unsigned char*) srcptr; + for ( int i = 0; i < size; i++ ) + dst[i] = src[i]; + return dstptr; +} + +int strlen(const char* string) +{ + int result = 0; + while ( string[result] ) + result++; + return result; +} -- cgit v1.2.3