From 9220447060be5996c9065f26ab8358f6b19f258e Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Tue, 23 Feb 2021 10:28:13 +0800 Subject: [PATCH] update --- bsp/efm32/copy_this_file_shell.c | 46 ---------------------- components/libc/compilers/newlib/minilib.c | 13 ++++++ 2 files changed, 13 insertions(+), 46 deletions(-) diff --git a/bsp/efm32/copy_this_file_shell.c b/bsp/efm32/copy_this_file_shell.c index 32b7439e0d..7cc7c6ebd6 100644 --- a/bsp/efm32/copy_this_file_shell.c +++ b/bsp/efm32/copy_this_file_shell.c @@ -32,52 +32,6 @@ ALIGN(RT_ALIGN_SIZE) static char finsh_thread_stack[FINSH_THREAD_STACK_SIZE]; struct finsh_shell* shell; -#ifdef RT_USING_HEAP -char *strdup(const char *s) -{ - size_t len = strlen(s) + 1; - char *tmp = (char *)rt_malloc(len); - - if(!tmp) return NULL; - - rt_memcpy(tmp, s, len); - return tmp; -} -#endif - -#if !defined(__CC_ARM) && !defined(__IAR_SYSTEMS_ICC__) -int isalpha( int ch ) -{ - return (unsigned int)((ch | 0x20) - 'a') < 26u; -} - -int atoi(const char* s) -{ - long int v=0; - int sign=1; - while ( *s == ' ' || (unsigned int)(*s - 9) < 5u) s++; - - switch (*s) - { - case '-': sign=-1; - case '+': ++s; - } - - while ((unsigned int) (*s - '0') < 10u) - { - v=v*10+*s-'0'; ++s; - } - - return sign==-1?-v:v; -} - -int isprint(unsigned char ch) -{ - return (unsigned int)(ch - ' ') < 127u - ' '; -} -#endif -#endif - #if defined(RT_USING_DFS) && defined(DFS_USING_WORKDIR) #include const char* finsh_get_prompt(void) diff --git a/components/libc/compilers/newlib/minilib.c b/components/libc/compilers/newlib/minilib.c index 2d07eabe5a..1210880b96 100644 --- a/components/libc/compilers/newlib/minilib.c +++ b/components/libc/compilers/newlib/minilib.c @@ -16,3 +16,16 @@ void * _sbrk_r(struct _reent *ptr, ptrdiff_t incr) /* no use this routine to get memory */ return RT_NULL; } + +#ifdef RT_USING_HEAP +char *strdup(const char *s) +{ + size_t len = strlen(s) + 1; + char *tmp = (char *)rt_malloc(len); + + if(!tmp) return NULL; + + rt_memcpy(tmp, s, len); + return tmp; +} +#endif /*RT_USING_HEAP*/