mbed library sources, mbed-dev only for TYBLE16

Fork of mbed-dev by mbed official

Please refer flowing link.
/users/kenjiArai/notebook/tyble16-module-will-become-a-mbed-family--mbedliza/

Revision:
181:57724642e740
Parent:
180:96ed750bd169
--- a/platform/mbed_alloc_wrappers.cpp	Wed Jan 17 15:23:54 2018 +0000
+++ b/platform/mbed_alloc_wrappers.cpp	Fri Feb 16 16:09:33 2018 +0000
@@ -81,12 +81,18 @@
     void * __real__realloc_r(struct _reent * r, void * ptr, size_t size);
     void __real__free_r(struct _reent * r, void * ptr);
     void* __real__calloc_r(struct _reent * r, size_t nmemb, size_t size);
+    void* malloc_wrapper(struct _reent * r, size_t size, void * caller);
+    void free_wrapper(struct _reent * r, void * ptr, void* caller);
 }
 
 // TODO: memory tracing doesn't work with uVisor enabled.
 #if !defined(FEATURE_UVISOR)
 
 extern "C" void * __wrap__malloc_r(struct _reent * r, size_t size) {
+    return malloc_wrapper(r, size, MBED_CALLER_ADDR());
+}
+
+extern "C" void * malloc_wrapper(struct _reent * r, size_t size, void * caller) {
     void *ptr = NULL;
 #ifdef MBED_MEM_TRACING_ENABLED
     mbed_mem_trace_lock();
@@ -111,7 +117,7 @@
     ptr = __real__malloc_r(r, size);
 #endif // #ifdef MBED_HEAP_STATS_ENABLED
 #ifdef MBED_MEM_TRACING_ENABLED
-    mbed_mem_trace_malloc(ptr, size, MBED_CALLER_ADDR());
+    mbed_mem_trace_malloc(ptr, size, caller);
     mbed_mem_trace_unlock();
 #endif // #ifdef MBED_MEM_TRACING_ENABLED
     return ptr;
@@ -160,6 +166,10 @@
 }
 
 extern "C" void __wrap__free_r(struct _reent * r, void * ptr) {
+    free_wrapper(r, ptr, MBED_CALLER_ADDR());
+}
+
+extern "C" void free_wrapper(struct _reent * r, void * ptr, void * caller) {
 #ifdef MBED_MEM_TRACING_ENABLED
     mbed_mem_trace_lock();
 #endif
@@ -177,7 +187,7 @@
     __real__free_r(r, ptr);
 #endif // #ifdef MBED_HEAP_STATS_ENABLED
 #ifdef MBED_MEM_TRACING_ENABLED
-    mbed_mem_trace_free(ptr, MBED_CALLER_ADDR());
+    mbed_mem_trace_free(ptr, caller);
     mbed_mem_trace_unlock();
 #endif // #ifdef MBED_MEM_TRACING_ENABLED
 }
@@ -245,9 +255,16 @@
     void *SUPER_REALLOC(void *ptr, size_t size);
     void *SUPER_CALLOC(size_t nmemb, size_t size);
     void SUPER_FREE(void *ptr);
+    void *malloc_wrapper(size_t size, void* caller);
+    void free_wrapper(void *ptr, void* caller);
 }
 
+
 extern "C" void* SUB_MALLOC(size_t size) {
+    return malloc_wrapper(size, MBED_CALLER_ADDR());
+}
+
+extern "C" void* malloc_wrapper(size_t size, void* caller) {
     void *ptr = NULL;
 #ifdef MBED_MEM_TRACING_ENABLED
     mbed_mem_trace_lock();
@@ -272,12 +289,13 @@
     ptr = SUPER_MALLOC(size);
 #endif // #ifdef MBED_HEAP_STATS_ENABLED
 #ifdef MBED_MEM_TRACING_ENABLED
-    mbed_mem_trace_malloc(ptr, size, MBED_CALLER_ADDR());
+    mbed_mem_trace_malloc(ptr, size, caller);
     mbed_mem_trace_unlock();
 #endif // #ifdef MBED_MEM_TRACING_ENABLED
     return ptr;
 }
 
+
 extern "C" void* SUB_REALLOC(void *ptr, size_t size) {
     void *new_ptr = NULL;
 #ifdef MBED_MEM_TRACING_ENABLED
@@ -337,6 +355,10 @@
 }
 
 extern "C" void SUB_FREE(void *ptr) {
+    free_wrapper(ptr, MBED_CALLER_ADDR());
+}
+
+extern "C" void free_wrapper(void *ptr, void* caller) {
 #ifdef MBED_MEM_TRACING_ENABLED
     mbed_mem_trace_lock();
 #endif
@@ -354,7 +376,7 @@
     SUPER_FREE(ptr);
 #endif // #ifdef MBED_HEAP_STATS_ENABLED
 #ifdef MBED_MEM_TRACING_ENABLED
-    mbed_mem_trace_free(ptr, MBED_CALLER_ADDR());
+    mbed_mem_trace_free(ptr, caller);
     mbed_mem_trace_unlock();
 #endif // #ifdef MBED_MEM_TRACING_ENABLED
 }