From 974e1252eee8d391721efd8a9f959ccf81458fe4 Mon Sep 17 00:00:00 2001 From: Nam Cao Date: Tue, 29 Nov 2022 10:00:35 +0100 Subject: [PATCH] Rewrite append_data() to call insert_data() append_data() and insert_data() have almost the same implementation. Change append_data() to simply call insert_data(). --- elfio/elfio_section.hpp | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/elfio/elfio_section.hpp b/elfio/elfio_section.hpp index 91a44cd..dc6e352 100644 --- a/elfio/elfio_section.hpp +++ b/elfio/elfio_section.hpp @@ -161,31 +161,7 @@ template class section_impl : public section //------------------------------------------------------------------------------ void append_data( const char* raw_data, Elf_Word size ) override { - if ( get_type() != SHT_NOBITS ) { - if ( get_size() + size < data_size ) { - std::copy( raw_data, raw_data + size, data.get() + get_size() ); - } - else { - data_size = 2 * ( data_size + size ); - std::unique_ptr new_data( - new ( std::nothrow ) char[data_size] ); - - if ( nullptr != new_data ) { - std::copy( data.get(), data.get() + get_size(), - new_data.get() ); - std::copy( raw_data, raw_data + size, - new_data.get() + get_size() ); - data = std::move( new_data ); - } - else { - size = 0; - } - } - set_size( get_size() + size ); - if ( translator->empty() ) { - set_stream_size( get_stream_size() + size ); - } - } + insert_data( get_size(), raw_data, size ); } //------------------------------------------------------------------------------