Skip to content

Commit fff959e

Browse files
author
Stuart Cording
committed
Fixed endOfData() function.
Function needed to return false on last entry in map (map::rend), not at map::end. Fixed to resolve this.
1 parent ba8eb1e commit fff959e

File tree

1 file changed

+44
-2
lines changed

1 file changed

+44
-2
lines changed

intelhex_class/intelhexclass.h

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,12 @@ class intelhex {
637637

638638
if (!ihContent.empty())
639639
{
640-
if (ihIterator != ihContent.end())
640+
map<unsigned long, unsigned char>::iterator it \
641+
= ihContent.end();
642+
643+
--it;
644+
645+
if (it != ihIterator)
641646
{
642647
result = false;
643648
}
@@ -845,7 +850,44 @@ class intelhex {
845850
return false;
846851
}
847852

848-
bool getData(unsigned char * data, unsigned long address);
853+
/**********************************************************************/
854+
/*! \brief Returns the data for desired address.
855+
*
856+
* Returns the data for the desired address. If the address has no data
857+
* assigned to it, the function returns false, the pointer to data is not
858+
* written and the class's address pointer remains unchanged. If the
859+
* address has data assigned to it, the pointer to data will be written
860+
* with the data found and the class's address pointer will be moved to
861+
* this new location.
862+
*
863+
* \param data - variable to hold data requested
864+
* \param address - address to be queried for valid data
865+
*
866+
* \retval true - data was available and returned value is valid
867+
* \retval false - data was not available and returned valid is not
868+
* valid
869+
*
870+
* \sa putData()
871+
***********************************************************************/
872+
bool getData(unsigned char * data, unsigned long address)
873+
{
874+
bool found = false;
875+
map<unsigned long, unsigned char>::iterator localIterator;
876+
877+
if (!ihContent.empty())
878+
{
879+
localIterator = ihContent.find(address);
880+
881+
if (localIterator != ihContent.end())
882+
{
883+
found = true;
884+
ihIterator = localIterator;
885+
*data = ihIterator->second;
886+
}
887+
}
888+
889+
return found;
890+
}
849891

850892
/**********************************************************************/
851893
/*! \brief Inserts desired byte at the current address pointer.

0 commit comments

Comments
 (0)