Browse Source

add malloc, realloc etc implementation in minilibc.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1452 bbd45198-f89e-11dd-88c7-29a3b14d5316
bernard.xiong@gmail.com 14 years ago
parent
commit
b2c7d265f2
2 changed files with 26 additions and 6 deletions
  1. 20 0
      components/libc/minilibc/stdlib.c
  2. 6 6
      components/libc/minilibc/stdlib.h

+ 20 - 0
components/libc/minilibc/stdlib.c

@@ -38,4 +38,24 @@ int atoi(const char* s)
 	return sign==-1?-v:v;
 }
 
+void *malloc(size_t size)
+{
+	return rt_malloc(size);
+}
+
+void free(void *ptr)
+{
+	rt_free(ptr);
+}
+
+void *realloc(void *ptr, size_t size)
+{
+	return rt_realloc(ptr, size);
+}
+
+void *calloc(size_t nelem, size_t elsize)
+{
+	return rt_calloc(nelem, elsize);
+}
+
 #endif

+ 6 - 6
components/libc/minilibc/stdlib.h

@@ -19,12 +19,6 @@
 
 #if !defined (RT_USING_NEWLIB) && defined (RT_USING_MINILIBC)
 int atoi(const char *nptr);
-#endif
-
-#define malloc  rt_malloc
-#define free    rt_free
-#define realloc rt_realloc
-#define calloc  rt_calloc
 
 int rand(void);
 int rand_r(unsigned int *seed);
@@ -32,4 +26,10 @@ void srand(unsigned int seed);
 
 void qsort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *));
 
+void *malloc(size_t size);
+void free(void *ptr);
+void *realloc(void *ptr, size_t size);
+void *calloc(size_t nelem, size_t elsize);
+#endif
+
 #endif