Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: HelloWorld_CCA01M1 HelloWorld_CCA02M1 CI-data-logger-server HelloWorld_CCA02M1 ... more
This is a fork of the events subdirectory of https://github.com/ARMmbed/mbed-os.
Note, you must import this library with import name: events!!!
Diff: hal/common/mbed_alloc_wrappers.cpp
- Revision:
- 7606:dbabbb13e5b0
- Parent:
- 7604:4544d30abb2a
- Child:
- 7813:04b3c320bf04
- Child:
- 7649:2edb2f062201
diff -r 932e3c18b649 -r dbabbb13e5b0 hal/common/mbed_alloc_wrappers.cpp
--- a/hal/common/mbed_alloc_wrappers.cpp Mon Aug 22 18:54:07 2016 +0300
+++ b/hal/common/mbed_alloc_wrappers.cpp Tue Aug 23 17:09:27 2016 +0300
@@ -47,6 +47,7 @@
} alloc_info_t;
static SingletonPtr<PlatformMutex> malloc_stats_mutex;
+static SingletonPtr<PlatformMutex> mem_trace_mutex;
static mbed_stats_heap_t heap_stats = {0, 0, 0, 0, 0};
void mbed_stats_heap_get(mbed_stats_heap_t *stats)
@@ -98,7 +99,9 @@
ptr = __real__malloc_r(r, size);
#endif // #ifdef MBED_HEAP_STATS_ENABLED
#ifdef MBED_MEM_TRACING_ENABLED
+ mem_trace_mutex->lock();
mbed_mem_trace_malloc(ptr, size, MBED_CALLER_ADDR());
+ mem_trace_mutex->unlock();
#endif // #ifdef MBED_MEM_TRACING_ENABLED
return ptr;
}
@@ -136,7 +139,9 @@
new_ptr = __real__realloc_r(r, ptr, size);
#endif // #ifdef MBED_HEAP_STATS_ENABLED
#ifdef MBED_MEM_TRACING_ENABLED
+ mem_trace_mutex->lock();
mbed_mem_trace_realloc(new_ptr, ptr, size, MBED_CALLER_ADDR());
+ mem_trace_mutex->unlock();
#endif // #ifdef MBED_MEM_TRACING_ENABLED
return new_ptr;
}
@@ -156,7 +161,9 @@
__real__free_r(r, ptr);
#endif // #ifdef MBED_HEAP_STATS_ENABLED
#ifdef MBED_MEM_TRACING_ENABLED
+ mem_trace_mutex->lock();
mbed_mem_trace_free(ptr, MBED_CALLER_ADDR());
+ mem_trace_mutex->unlock();
#endif // #ifdef MBED_MEM_TRACING_ENABLED
}
@@ -173,7 +180,9 @@
ptr = __real__calloc_r(r, nmemb, size);
#endif // #ifdef MBED_HEAP_STATS_ENABLED
#ifdef MBED_MEM_TRACING_ENABLED
+ mem_trace_mutex->lock();
mbed_mem_trace_calloc(ptr, nmemb, size, MBED_CALLER_ADDR());
+ mem_trace_mutex->unlock();
#endif // #ifdef MBED_MEM_TRACING_ENABLED
return ptr;
}
@@ -218,7 +227,9 @@
ptr = $Super$$malloc(size);
#endif // #ifdef MBED_HEAP_STATS_ENABLED
#ifdef MBED_MEM_TRACING_ENABLED
+ mem_trace_mutex->lock();
mbed_mem_trace_malloc(ptr, size, MBED_CALLER_ADDR());
+ mem_trace_mutex->unlock();
#endif // #ifdef MBED_MEM_TRACING_ENABLED
return ptr;
}
@@ -248,7 +259,9 @@
free(ptr);
}
#else // #ifdef MBED_HEAP_STATS_ENABLED
+ mem_trace_mutex->lock();
new_ptr = $Super$$realloc(ptr, size);
+ mem_trace_mutex->unlock();
#endif // #ifdef MBED_HEAP_STATS_ENABLED
#ifdef MBED_MEM_TRACING_ENABLED
mbed_mem_trace_realloc(new_ptr, ptr, size, MBED_CALLER_ADDR());
@@ -268,7 +281,9 @@
ptr = $Super$$calloc(nmemb, size);
#endif // #ifdef MBED_HEAP_STATS_ENABLED
#ifdef MBED_MEM_TRACING_ENABLED
+ mem_trace_mutex->lock();
mbed_mem_trace_calloc(ptr, nmemb, size, MBED_CALLER_ADDR());
+ mem_trace_mutex->unlock();
#endif // #ifdef MBED_MEM_TRACING_ENABLED
return ptr;
}
@@ -288,7 +303,9 @@
$Super$$free(ptr);
#endif // #ifdef MBED_HEAP_STATS_ENABLED
#ifdef MBED_MEM_TRACING_ENABLED
+ mem_trace_mutex->lock();
mbed_mem_trace_free(ptr, MBED_CALLER_ADDR());
+ mem_trace_mutex->unlock();
#endif // #ifdef MBED_MEM_TRACING_ENABLED
}