diff --git a/include/intelhex.h b/include/intelhex.h index 428a701..84d23b1 100644 --- a/include/intelhex.h +++ b/include/intelhex.h @@ -67,7 +67,7 @@ namespace intelhex value_type& operator[](address_type); //Array access operator value_type get(address_type); // Return the value at address - void set(address_type, value_type); // Set the value at address + void set(address_type, value_type, bool ignore_fill=false); // Set the value at address void load(const std::string&); // Load from a file void read(std::istream &); // Read data from an input stream diff --git a/src/intelhex.cc b/src/intelhex.cc index f4f0ebb..6b34659 100644 --- a/src/intelhex.cc +++ b/src/intelhex.cc @@ -56,9 +56,9 @@ namespace intelhex } // Set the value at address or create a new element using value - void hex_data::set(address_type address, value_type value) + void hex_data::set(address_type address, value_type value, bool ignore_fill) { - if( value == fill() ) // Handle fill values + if( !ignore_fill && value == fill() ) // Handle fill values { erase(address); // If the address is already set, erase it return; @@ -290,7 +290,7 @@ namespace intelhex while( (i!=blocks.rend()) && (i->first > addr)) ++i; - if( (addr - i->first) > i->second.size() ) + if( (addr - i->first) >= i->second.size() ) return false; else return true;