diff --git a/elfio/elfio_section.hpp b/elfio/elfio_section.hpp index e36944d..38f5fd1 100644 --- a/elfio/elfio_section.hpp +++ b/elfio/elfio_section.hpp @@ -100,10 +100,13 @@ template class section_impl : public section std::string get_name() const override { return name; } //------------------------------------------------------------------------------ - void set_name( std::string name_prm ) override { this->name = name_prm; } + void set_name( const std::string& name_prm ) override + { + this->name = name_prm; + } //------------------------------------------------------------------------------ - void set_address( Elf64_Addr value ) override + void set_address( const Elf64_Addr& value ) override { header.sh_addr = decltype( header.sh_addr )( value ); header.sh_addr = ( *convertor )( header.sh_addr ); @@ -190,7 +193,7 @@ template class section_impl : public section ELFIO_GET_SET_ACCESS( Elf64_Off, offset, header.sh_offset ); //------------------------------------------------------------------------------ - void set_index( Elf_Half value ) override { index = value; } + void set_index( const Elf_Half& value ) override { index = value; } //------------------------------------------------------------------------------ bool load( std::istream& stream, std::streampos header_offset ) override diff --git a/elfio/elfio_segment.hpp b/elfio/elfio_segment.hpp index 8deea5a..c9d4a87 100644 --- a/elfio/elfio_segment.hpp +++ b/elfio/elfio_segment.hpp @@ -134,7 +134,7 @@ template class segment_impl : public segment //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ - void set_offset( Elf64_Off value ) override + void set_offset( const Elf64_Off& value ) override { ph.p_offset = decltype( ph.p_offset )( value ); ph.p_offset = ( *convertor )( ph.p_offset ); @@ -151,7 +151,7 @@ template class segment_impl : public segment } //------------------------------------------------------------------------------ - void set_index( Elf_Half value ) override { index = value; } + void set_index( const Elf_Half& value ) override { index = value; } //------------------------------------------------------------------------------ bool load( std::istream& stream, std::streampos header_offset ) override diff --git a/elfio/elfio_utils.hpp b/elfio/elfio_utils.hpp index 980f888..1e99960 100644 --- a/elfio/elfio_utils.hpp +++ b/elfio/elfio_utils.hpp @@ -29,24 +29,24 @@ THE SOFTWARE. #define ELFIO_GET_ACCESS_DECL( TYPE, NAME ) virtual TYPE get_##NAME() const = 0 #define ELFIO_SET_ACCESS_DECL( TYPE, NAME ) \ - virtual void set_##NAME( TYPE value ) = 0 + virtual void set_##NAME( const TYPE& value ) = 0 -#define ELFIO_GET_SET_ACCESS_DECL( TYPE, NAME ) \ - virtual TYPE get_##NAME() const = 0; \ - virtual void set_##NAME( TYPE value ) = 0 +#define ELFIO_GET_SET_ACCESS_DECL( TYPE, NAME ) \ + virtual TYPE get_##NAME() const = 0; \ + virtual void set_##NAME( const TYPE& value ) = 0 #define ELFIO_GET_ACCESS( TYPE, NAME, FIELD ) \ TYPE get_##NAME() const override { return ( *convertor )( FIELD ); } -#define ELFIO_SET_ACCESS( TYPE, NAME, FIELD ) \ - void set_##NAME( TYPE value ) override \ - { \ - FIELD = decltype( FIELD )( value ); \ - FIELD = ( *convertor )( FIELD ); \ +#define ELFIO_SET_ACCESS( TYPE, NAME, FIELD ) \ + void set_##NAME( const TYPE& value ) override \ + { \ + FIELD = decltype( FIELD )( value ); \ + FIELD = ( *convertor )( FIELD ); \ } #define ELFIO_GET_SET_ACCESS( TYPE, NAME, FIELD ) \ TYPE get_##NAME() const override { return ( *convertor )( FIELD ); } \ - void set_##NAME( TYPE value ) override \ + void set_##NAME( const TYPE& value ) override \ { \ FIELD = decltype( FIELD )( value ); \ FIELD = ( *convertor )( FIELD ); \