fdsg

Dependencies:   BLE_API MicroBitEffectsPedal nRF51822

Fork of microbit-dal by Lancaster University

Revision:
35:8ce23bc1af38
Parent:
32:ece16b5987dd
Child:
37:b624ae5e94a5
--- a/source/drivers/MicroBitStorage.cpp	Wed Jul 13 12:18:13 2016 +0100
+++ b/source/drivers/MicroBitStorage.cpp	Wed Jul 13 12:18:14 2016 +0100
@@ -209,22 +209,14 @@
   *
   * @param data a pointer to the beginning of the data to be persisted.
   *
-  * @param dataSize the size of the data to be persisted
-  *
-  * @return MICROBIT_OK on success, MICROBIT_INVALID_PARAMETER if the key or size is too large,
-  *         MICROBIT_NO_RESOURCES if the storage page is full
+  * @return MICROBIT_OK on success, or MICROBIT_NO_RESOURCES if the storage page is full
   */
-int MicroBitStorage::put(const char *key, uint8_t *data, int dataSize)
+int MicroBitStorage::put(const char *key, uint8_t *data)
 {
     KeyValuePair pair = KeyValuePair();
 
-    int keySize = strlen(key) + 1;
-
-    if(keySize > (int)sizeof(pair.key) || dataSize > (int)sizeof(pair.value) || dataSize < 0)
-        return MICROBIT_INVALID_PARAMETER;
-
-    memcpy(pair.key, key, keySize);
-    memcpy(pair.value, data, dataSize);
+    memcpy(pair.key, key, min(sizeof(pair.key), strlen(key)));
+    memcpy(pair.value, data, sizeof(pair.value));
 
     //calculate our various offsets.
     uint32_t pg_size = NRF_FICR->CODEPAGESIZE;
@@ -298,14 +290,11 @@
   *
   * @param data a pointer to the beginning of the data to be persisted.
   *
-  * @param dataSize the size of the data to be persisted
-  *
-  * @return MICROBIT_OK on success, MICROBIT_INVALID_PARAMETER if the key or size is too large,
-  *         MICROBIT_NO_RESOURCES if the storage page is full
+  * @return MICROBIT_OK on success, or MICROBIT_NO_RESOURCES if the storage page is full
   */
-int MicroBitStorage::put(ManagedString key, uint8_t* data, int dataSize)
+int MicroBitStorage::put(ManagedString key, uint8_t* data)
 {
-    return put((char *)key.toCharArray(), data, dataSize);
+    return put((char *)key.toCharArray(), data);
 }
 
 /**