mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Revision:
189:f392fc9709a3
Parent:
187:0387e8f68319
--- a/platform/mbed_mem_trace.cpp	Thu Nov 08 11:46:34 2018 +0000
+++ b/platform/mbed_mem_trace.cpp	Wed Feb 20 22:31:08 2019 +0000
@@ -1,5 +1,6 @@
 /* mbed Microcontroller Library
  * Copyright (c) 2006-2016 ARM Limited
+ * SPDX-License-Identifier: Apache-2.0
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,6 +29,7 @@
 
 /* The callback function that will be called after a traced memory operations finishes. */
 static mbed_mem_trace_cb_t mem_trace_cb;
+static mbed_mem_trace_cb_t mem_trace_cb_reserve;
 /* 'trace_lock_count' guards "trace inside trace" situations (for example, the implementation
  * of realloc() might call malloc() internally, and since malloc() is also traced, this could
  * result in two calls to the callback function instead of one. */
@@ -46,6 +48,24 @@
     mem_trace_cb = cb;
 }
 
+void mbed_mem_trace_disable()
+{
+    mbed_mem_trace_lock();
+    if (mem_trace_cb) {
+        mem_trace_cb_reserve = mem_trace_cb;
+        mem_trace_cb = 0;
+    }
+    mbed_mem_trace_unlock();
+}
+void mbed_mem_trace_enable()
+{
+    mbed_mem_trace_lock();
+    if (!mem_trace_cb && mem_trace_cb_reserve) {
+        mem_trace_cb = mem_trace_cb_reserve;
+    }
+    mbed_mem_trace_unlock();
+}
+
 void mbed_mem_trace_lock()
 {
     mem_trace_mutex->lock();