mirror of
https://github.com/serge1/ELFIO.git
synced 2024-11-19 11:14:46 +00:00
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().
This commit is contained in:
parent
e533985a3c
commit
974e1252ee
@ -161,31 +161,7 @@ template <class T> 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<char[]> 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 );
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user