From 2adda59b6da3cd4b088dfa9d45c0b4eddbc1b186 Mon Sep 17 00:00:00 2001 From: Bundit J Date: Sat, 18 Apr 2015 16:08:36 +0700 Subject: [PATCH] Add get and put functions to EEPROM As available in http://www.arduino.cc/en/Reference/EEPROM --- libraries/EEPROM/EEPROM.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/EEPROM/EEPROM.h b/libraries/EEPROM/EEPROM.h index c51f759b7..961ff8b08 100644 --- a/libraries/EEPROM/EEPROM.h +++ b/libraries/EEPROM/EEPROM.h @@ -37,7 +37,7 @@ class EEPROMClass template T &get(int address, T &t) { - if (address < 0 || address >= _size) + if (address < 0 || address + sizeof(T) > _size) return t; uint8_t *ptr = (uint8_t*) &t; @@ -47,7 +47,7 @@ class EEPROMClass template const T &put(int address, const T &t) { - if (address < 0 || address >= _size) + if (address < 0 || address + sizeof(T) > _size) return t; const uint8_t *ptr = (const uint8_t*) &t;