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.
Dependencies: BLE_API mbed-dev-bin nRF51822
Fork of microbit-dal by
Diff: source/drivers/MicroBitStorage.cpp
- Revision:
- 48:34d1adb6771c
- Parent:
- 37:b624ae5e94a5
--- a/source/drivers/MicroBitStorage.cpp Wed Jul 13 12:18:26 2016 +0100
+++ b/source/drivers/MicroBitStorage.cpp Wed Jul 13 12:18:27 2016 +0100
@@ -223,6 +223,16 @@
if(keySize > (int)sizeof(pair.key) || dataSize > (int)sizeof(pair.value) || dataSize < 0)
return MICROBIT_INVALID_PARAMETER;
+ KeyValuePair *currentValue = get(key);
+
+ int upToDate = currentValue && (memcmp(currentValue->value, data, dataSize) == 0);
+
+ if(currentValue)
+ delete currentValue;
+
+ if(upToDate)
+ return MICROBIT_OK;
+
memcpy(pair.key, key, keySize);
memcpy(pair.value, data, dataSize);
