Skip to content

Commit 7795695

Browse files
committed
Add get and put functions to EEPROM
As available in http://www.arduino.cc/en/Reference/EEPROM
1 parent 69158c2 commit 7795695

File tree

1 file changed

+2
-2
lines changed
  • hardware/esp8266com/esp8266/libraries/EEPROM

1 file changed

+2
-2
lines changed

hardware/esp8266com/esp8266/libraries/EEPROM/EEPROM.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class EEPROMClass
3737

3838
template<typename T> T &get(int address, T &t)
3939
{
40-
if (address < 0 || address >= _size)
40+
if (address < 0 || address + sizeof(T) > _size)
4141
return t;
4242

4343
uint8_t *ptr = (uint8_t*) &t;
@@ -47,7 +47,7 @@ class EEPROMClass
4747

4848
template<typename T> const T &put(int address, const T &t)
4949
{
50-
if (address < 0 || address >= _size)
50+
if (address < 0 || address + sizeof(T) > _size)
5151
return t;
5252

5353
const uint8_t *ptr = (const uint8_t*) &t;

0 commit comments

Comments
 (0)