libs,klib,string: remove assert

* assert will introduce printf in some cputest, increasing the
  complexity of the binary
This commit is contained in:
Zihao Yu 2017-07-23 11:48:05 +08:00
parent e027eb1b41
commit f303137685
1 changed files with 0 additions and 10 deletions

View File

@ -1,7 +1,6 @@
#include "klib.h"
size_t strlen(const char *s) {
assert(s);
size_t sz = 0;
for (; *s; s ++) {
sz ++;
@ -10,14 +9,12 @@ size_t strlen(const char *s) {
}
char* strcpy(char* dst,const char* src){
assert(src&&dst);
char* ret;
ret=dst;
while((*dst++=*src++)!='\0');
return ret;
}
char* strncpy(char* dst, const char* src, size_t n){
assert(src&&dst);
char* ret;
ret=dst;
while(n-->0){
@ -27,27 +24,22 @@ char* strncpy(char* dst, const char* src, size_t n){
}
char* strcat(char* dst, const char* src){
assert(dst&&src);
char* d=dst;
while(*++dst!='\0');
while((*dst++=*src++)!='\0');
return d;
}
int strcmp(const char* s1, const char* s2){
assert(s1&&s2);
while(*s1&&*s1==*s2)s1++,s2++;
return (int)(*s1-*s2);
}
int strncmp(const char* s1, const char* s2, size_t n){
assert(s1&&s2);
while(--n>0&&*s1&&*s1==*s2)s1++,s2++;
return (int)(*s1-*s2);
}
void* memset(void* v,int c,size_t n){
assert(v);
c &= 0xff;
uint32_t c2 = (c << 8) | c;
uint32_t c4 = (c2 << 16) | c2;
@ -69,7 +61,6 @@ void* memset(void* v,int c,size_t n){
}
void* memmove(void* dst,const void* src,size_t n){
assert(dst&&src);
const char* s;
char* d;
if(src+n>dst&&src<dst){
@ -85,7 +76,6 @@ void* memmove(void* dst,const void* src,size_t n){
return dst;
}
void* memcpy(void* dst, const void* src, size_t n){
assert(dst&&src);
int n_align = n & ~0xf;
int i;