mirror of
https://github.com/wiiu-env/WUMSLoader.git
synced 2024-12-25 23:51:50 +01:00
Tweaking some compiler options
This commit is contained in:
parent
a45d0d092d
commit
b17b522d6b
4
Makefile
4
Makefile
@ -31,12 +31,12 @@ INCLUDES := source
|
||||
#-------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#-------------------------------------------------------------------------------
|
||||
CFLAGS := -g -Wall -O2 -ffunction-sections \
|
||||
CFLAGS := -g -Wall -O3 -ffunction-sections -fno-exceptions -fno-rtti\
|
||||
$(MACHDEP)
|
||||
|
||||
CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__
|
||||
|
||||
CXXFLAGS := $(CFLAGS) -std=c++17
|
||||
CXXFLAGS := $(CFLAGS) -std=c++20
|
||||
|
||||
ASFLAGS := -g $(ARCH)
|
||||
LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map)
|
||||
|
@ -42,8 +42,8 @@ INCLUDES := src
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
CFLAGS := -g -Wall -O2 -ffunction-sections $(MACHDEP) $(INCLUDE) -D__WIIU__ -D__WUT__
|
||||
CXXFLAGS := $(CFLAGS) -std=c++17
|
||||
CFLAGS := -g -Wall -O3 -ffunction-sections -fno-exceptions -fno-rtti $(MACHDEP) $(INCLUDE) -D__WIIU__ -D__WUT__
|
||||
CXXFLAGS := $(CFLAGS) -std=c++20
|
||||
ASFLAGS := -mregnames
|
||||
LDFLAGS := -nostartfiles -Wl,--gc-sections
|
||||
|
||||
|
@ -17,7 +17,7 @@ int32_t LoadFileToMem(const char *relativefilepath, char **fileOut, uint32_t *si
|
||||
int result = 0;
|
||||
char *sdRootPath = NULL;
|
||||
if (!WHBMountSdCard()) {
|
||||
WHBLogPrintf("Failed to mount SD Card...");
|
||||
DEBUG_FUNCTION_LINE("Failed to mount SD Card...");
|
||||
result = -1;
|
||||
goto exit;
|
||||
}
|
||||
@ -25,12 +25,12 @@ int32_t LoadFileToMem(const char *relativefilepath, char **fileOut, uint32_t *si
|
||||
sdRootPath = WHBGetSdCardMountPath();
|
||||
sprintf(path, "%s/%s", sdRootPath, relativefilepath);
|
||||
|
||||
WHBLogPrintf("Loading file %s.", path);
|
||||
DEBUG_FUNCTION_LINE("Loading file %s.", path);
|
||||
|
||||
*fileOut = WHBReadWholeFile(path, sizeOut);
|
||||
if (!(*fileOut)) {
|
||||
result = -2;
|
||||
WHBLogPrintf("WHBReadWholeFile(%s) returned NULL", path);
|
||||
DEBUG_FUNCTION_LINE("WHBReadWholeFile(%s) returned NULL", path);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
@ -67,50 +67,74 @@ set_##FNAME( TYPE val ) \
|
||||
} \
|
||||
} \
|
||||
|
||||
struct membuf : std::streambuf {
|
||||
membuf(char* begin, char* end) {
|
||||
this->setg(begin, begin, end);
|
||||
}
|
||||
|
||||
pos_type seekoff(off_type off, std::ios_base::seekdir dir, std::ios_base::openmode which = std::ios_base::in) override {
|
||||
if (dir == std::ios_base::cur)
|
||||
gbump(off);
|
||||
else if (dir == std::ios_base::end)
|
||||
setg(eback(), egptr() + off, egptr());
|
||||
else if (dir == std::ios_base::beg)
|
||||
setg(eback(), eback() + off, egptr());
|
||||
return gptr() - eback();
|
||||
}
|
||||
|
||||
pos_type seekpos(pos_type sp, std::ios_base::openmode which) override {
|
||||
return seekoff(sp - pos_type(off_type(0)), std::ios_base::beg, which);
|
||||
}
|
||||
};
|
||||
|
||||
namespace ELFIO {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
class elfio
|
||||
{
|
||||
class elfio {
|
||||
public:
|
||||
//------------------------------------------------------------------------------
|
||||
elfio() : sections( this ), segments( this )
|
||||
{
|
||||
elfio() : sections( this ), segments( this ) {
|
||||
header = 0;
|
||||
current_file_pos = 0;
|
||||
create( ELFCLASS32, ELFDATA2LSB );
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
~elfio()
|
||||
{
|
||||
~elfio() {
|
||||
clean();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void create( unsigned char file_class, unsigned char encoding )
|
||||
{
|
||||
void create( unsigned char file_class, unsigned char encoding ) {
|
||||
clean();
|
||||
convertor.setup( encoding );
|
||||
header = create_header( file_class, encoding );
|
||||
create_mandatory_sections();
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool load( const std::string& file_name )
|
||||
{
|
||||
bool load(char * buffer, size_t length) {
|
||||
membuf sbuf(buffer, buffer + length);
|
||||
std::istream in(&sbuf);
|
||||
return load(in);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool load( const std::string& file_name ) {
|
||||
std::ifstream stream;
|
||||
stream.open( file_name.c_str(), std::ios::in | std::ios::binary );
|
||||
if ( !stream ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return load(stream);
|
||||
auto res = load(stream);
|
||||
stream.close();
|
||||
return res;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool load( std::istream &stream )
|
||||
{
|
||||
bool load( std::istream &stream ) {
|
||||
clean();
|
||||
|
||||
unsigned char e_ident[EI_NIDENT];
|
||||
@ -146,8 +170,7 @@ class elfio
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool save( const std::string& file_name )
|
||||
{
|
||||
bool save( const std::string& file_name ) {
|
||||
std::ofstream stream;
|
||||
stream.open( file_name.c_str(), std::ios::out | std::ios::binary );
|
||||
if ( !stream ) {
|
||||
@ -158,8 +181,7 @@ class elfio
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool save( std::ostream &stream )
|
||||
{
|
||||
bool save( std::ostream &stream ) {
|
||||
if ( !stream || !header) {
|
||||
return false;
|
||||
}
|
||||
@ -212,41 +234,35 @@ class elfio
|
||||
ELFIO_HEADER_ACCESS_GET_SET( Elf_Half, section_name_str_index );
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
const endianess_convertor& get_convertor() const
|
||||
{
|
||||
const endianess_convertor& get_convertor() const {
|
||||
return convertor;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Elf_Xword get_default_entry_size( Elf_Word section_type ) const
|
||||
{
|
||||
Elf_Xword get_default_entry_size( Elf_Word section_type ) const {
|
||||
switch( section_type ) {
|
||||
case SHT_RELA:
|
||||
if ( header->get_class() == ELFCLASS64 ) {
|
||||
return sizeof( Elf64_Rela );
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return sizeof( Elf32_Rela );
|
||||
}
|
||||
case SHT_REL:
|
||||
if ( header->get_class() == ELFCLASS64 ) {
|
||||
return sizeof( Elf64_Rel );
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return sizeof( Elf32_Rel );
|
||||
}
|
||||
case SHT_SYMTAB:
|
||||
if ( header->get_class() == ELFCLASS64 ) {
|
||||
return sizeof( Elf64_Sym );
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return sizeof( Elf32_Sym );
|
||||
}
|
||||
case SHT_DYNAMIC:
|
||||
if ( header->get_class() == ELFCLASS64 ) {
|
||||
return sizeof( Elf64_Dyn );
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return sizeof( Elf32_Dyn );
|
||||
}
|
||||
default:
|
||||
@ -296,8 +312,7 @@ class elfio
|
||||
//------------------------------------------------------------------------------
|
||||
private:
|
||||
//------------------------------------------------------------------------------
|
||||
void clean()
|
||||
{
|
||||
void clean() {
|
||||
delete header;
|
||||
header = 0;
|
||||
|
||||
@ -315,19 +330,16 @@ class elfio
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
elf_header* create_header( unsigned char file_class, unsigned char encoding )
|
||||
{
|
||||
elf_header* create_header( unsigned char file_class, unsigned char encoding ) {
|
||||
elf_header* new_header = 0;
|
||||
|
||||
if ( file_class == ELFCLASS64 ) {
|
||||
new_header = new elf_header_impl< Elf64_Ehdr >( &convertor,
|
||||
encoding );
|
||||
}
|
||||
else if ( file_class == ELFCLASS32 ) {
|
||||
} else if ( file_class == ELFCLASS32 ) {
|
||||
new_header = new elf_header_impl< Elf32_Ehdr >( &convertor,
|
||||
encoding );
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -335,18 +347,15 @@ class elfio
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
section* create_section()
|
||||
{
|
||||
section* create_section() {
|
||||
section* new_section;
|
||||
unsigned char file_class = get_class();
|
||||
|
||||
if ( file_class == ELFCLASS64 ) {
|
||||
new_section = new section_impl<Elf64_Shdr>( &convertor );
|
||||
}
|
||||
else if ( file_class == ELFCLASS32 ) {
|
||||
} else if ( file_class == ELFCLASS32 ) {
|
||||
new_section = new section_impl<Elf32_Shdr>( &convertor );
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -358,18 +367,15 @@ class elfio
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
segment* create_segment()
|
||||
{
|
||||
segment* create_segment() {
|
||||
segment* new_segment;
|
||||
unsigned char file_class = header->get_class();
|
||||
|
||||
if ( file_class == ELFCLASS64 ) {
|
||||
new_segment = new segment_impl<Elf64_Phdr>( &convertor );
|
||||
}
|
||||
else if ( file_class == ELFCLASS32 ) {
|
||||
} else if ( file_class == ELFCLASS32 ) {
|
||||
new_segment = new segment_impl<Elf32_Phdr>( &convertor );
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -380,8 +386,7 @@ class elfio
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void create_mandatory_sections()
|
||||
{
|
||||
void create_mandatory_sections() {
|
||||
// Create null section without calling to 'add_section' as no string
|
||||
// section containing section names exists yet
|
||||
section* sec0 = create_section();
|
||||
@ -396,8 +401,7 @@ class elfio
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Elf_Half load_sections( std::istream& stream )
|
||||
{
|
||||
Elf_Half load_sections( std::istream& stream ) {
|
||||
Elf_Half entry_size = header->get_section_entry_size();
|
||||
Elf_Half num = header->get_sections_num();
|
||||
Elf64_Off offset = header->get_sections_offset();
|
||||
@ -440,8 +444,7 @@ class elfio
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool load_segments( std::istream& stream )
|
||||
{
|
||||
bool load_segments( std::istream& stream ) {
|
||||
Elf_Half entry_size = header->get_segment_entry_size();
|
||||
Elf_Half num = header->get_segments_num();
|
||||
Elf64_Off offset = header->get_segments_offset();
|
||||
@ -452,11 +455,9 @@ class elfio
|
||||
|
||||
if ( file_class == ELFCLASS64 ) {
|
||||
seg = new segment_impl<Elf64_Phdr>( &convertor );
|
||||
}
|
||||
else if ( file_class == ELFCLASS32 ) {
|
||||
} else if ( file_class == ELFCLASS32 ) {
|
||||
seg = new segment_impl<Elf32_Phdr>( &convertor );
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -490,14 +491,12 @@ class elfio
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool save_header( std::ostream& stream )
|
||||
{
|
||||
bool save_header( std::ostream& stream ) {
|
||||
return header->save( stream );
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool save_sections( std::ostream& stream )
|
||||
{
|
||||
bool save_sections( std::ostream& stream ) {
|
||||
for ( unsigned int i = 0; i < sections_.size(); ++i ) {
|
||||
section *sec = sections_.at(i);
|
||||
|
||||
@ -511,8 +510,7 @@ class elfio
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool save_segments( std::ostream& stream )
|
||||
{
|
||||
bool save_segments( std::ostream& stream ) {
|
||||
for ( unsigned int i = 0; i < segments_.size(); ++i ) {
|
||||
segment *seg = segments_.at(i);
|
||||
|
||||
@ -525,8 +523,7 @@ class elfio
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool is_section_without_segment( unsigned int section_index )
|
||||
{
|
||||
bool is_section_without_segment( unsigned int section_index ) {
|
||||
bool found = false;
|
||||
|
||||
for ( unsigned int j = 0; !found && ( j < segments.size() ); ++j ) {
|
||||
@ -541,8 +538,7 @@ class elfio
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool is_subsequence_of( segment* seg1, segment* seg2 )
|
||||
{
|
||||
bool is_subsequence_of( segment* seg1, segment* seg2 ) {
|
||||
// Return 'true' if sections of seg1 are a subset of sections in seg2
|
||||
const std::vector<Elf_Half>& sections1 = seg1->get_sections();
|
||||
const std::vector<Elf_Half>& sections2 = seg2->get_sections();
|
||||
@ -557,8 +553,7 @@ class elfio
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
std::vector<segment*> get_ordered_segments( )
|
||||
{
|
||||
std::vector<segment*> get_ordered_segments( ) {
|
||||
std::vector<segment*> res;
|
||||
std::deque<segment*> worklist;
|
||||
|
||||
@ -601,8 +596,7 @@ class elfio
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool layout_sections_without_segments( )
|
||||
{
|
||||
bool layout_sections_without_segments( ) {
|
||||
for ( unsigned int i = 0; i < sections_.size(); ++i ) {
|
||||
if ( is_section_without_segment( i ) ) {
|
||||
section *sec = sections_[i];
|
||||
@ -628,8 +622,7 @@ class elfio
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void calc_segment_alignment( )
|
||||
{
|
||||
void calc_segment_alignment( ) {
|
||||
for( std::vector<segment*>::iterator s = segments_.begin(); s != segments_.end(); ++s ) {
|
||||
segment* seg = *s;
|
||||
for ( int i = 0; i < seg->get_sections_num(); ++i ) {
|
||||
@ -642,8 +635,7 @@ class elfio
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool layout_segments_and_their_sections( )
|
||||
{
|
||||
bool layout_segments_and_their_sections( ) {
|
||||
std::vector<segment*> worklist;
|
||||
std::vector<bool> section_generated(sections.size(),false);
|
||||
|
||||
@ -684,8 +676,7 @@ class elfio
|
||||
|
||||
current_file_pos += ( seg->get_align() + error ) % align;
|
||||
seg_start_pos = current_file_pos;
|
||||
}
|
||||
else if ( seg->get_sections_num() ) {
|
||||
} else if ( seg->get_sections_num() ) {
|
||||
seg_start_pos = sections[seg->get_section_index_at( 0 )]->get_offset();
|
||||
}
|
||||
|
||||
@ -717,8 +708,7 @@ class elfio
|
||||
return false;
|
||||
}
|
||||
secAlign = req_offset - cur_offset;
|
||||
}
|
||||
else if (!section_generated[index] && !sec->is_address_initialized() ) {
|
||||
} else if (!section_generated[index] && !sec->is_address_initialized() ) {
|
||||
// If no address has been specified then only the section
|
||||
// alignment constraint has to be matched
|
||||
Elf_Xword align = sec->get_addr_align();
|
||||
@ -727,8 +717,7 @@ class elfio
|
||||
}
|
||||
Elf64_Off error = current_file_pos % align;
|
||||
secAlign = ( align - error ) % align;
|
||||
}
|
||||
else if (section_generated[index] ) {
|
||||
} else if (section_generated[index] ) {
|
||||
// Alignment for already generated sections
|
||||
secAlign = sec->get_offset() - seg_start_pos - segment_filesize;
|
||||
}
|
||||
@ -779,8 +768,7 @@ class elfio
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool layout_section_table()
|
||||
{
|
||||
bool layout_section_table() {
|
||||
// Simply place the section table at the end for now
|
||||
Elf64_Off alignmentError = current_file_pos % 4;
|
||||
current_file_pos += ( 4 - alignmentError ) % 4;
|
||||
@ -796,19 +784,16 @@ class elfio
|
||||
public:
|
||||
//------------------------------------------------------------------------------
|
||||
Sections( elfio* parent_ ) :
|
||||
parent( parent_ )
|
||||
{
|
||||
parent( parent_ ) {
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Elf_Half size() const
|
||||
{
|
||||
Elf_Half size() const {
|
||||
return (Elf_Half)parent->sections_.size();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
section* operator[]( unsigned int index ) const
|
||||
{
|
||||
section* operator[]( unsigned int index ) const {
|
||||
section* sec = 0;
|
||||
|
||||
if ( index < parent->sections_.size() ) {
|
||||
@ -819,8 +804,7 @@ class elfio
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
section* operator[]( const std::string& name ) const
|
||||
{
|
||||
section* operator[]( const std::string& name ) const {
|
||||
section* sec = 0;
|
||||
|
||||
std::vector<section*>::const_iterator it;
|
||||
@ -837,8 +821,7 @@ class elfio
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
section* add( const std::string& name )
|
||||
{
|
||||
section* add( const std::string& name ) {
|
||||
section* new_section = parent->create_section();
|
||||
new_section->set_name( name );
|
||||
|
||||
@ -883,26 +866,22 @@ class elfio
|
||||
public:
|
||||
//------------------------------------------------------------------------------
|
||||
Segments( elfio* parent_ ) :
|
||||
parent( parent_ )
|
||||
{
|
||||
parent( parent_ ) {
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Elf_Half size() const
|
||||
{
|
||||
Elf_Half size() const {
|
||||
return (Elf_Half)parent->segments_.size();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
segment* operator[]( unsigned int index ) const
|
||||
{
|
||||
segment* operator[]( unsigned int index ) const {
|
||||
return parent->segments_[index];
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
segment* add()
|
||||
{
|
||||
segment* add() {
|
||||
return parent->create_segment();
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,7 @@ class relocation_section_accessor_template
|
||||
Elf_Half& section) const
|
||||
{
|
||||
// Do regular job
|
||||
Elf_Word symbol = 0;
|
||||
Elf_Word symbol;
|
||||
bool ret = get_entry( index, offset, symbol, type, addend );
|
||||
|
||||
// Find the symbol
|
||||
|
@ -161,13 +161,7 @@ class section_impl : public section
|
||||
{
|
||||
if ( get_type() != SHT_NOBITS ) {
|
||||
delete [] data;
|
||||
try {
|
||||
data = new char[size];
|
||||
} catch (const std::bad_alloc&) {
|
||||
data = 0;
|
||||
data_size = 0;
|
||||
size = 0;
|
||||
}
|
||||
if ( 0 != data && 0 != raw_data ) {
|
||||
data_size = size;
|
||||
std::copy( raw_data, raw_data + size, data );
|
||||
@ -195,12 +189,8 @@ class section_impl : public section
|
||||
else {
|
||||
data_size = 2*( data_size + size);
|
||||
char* new_data;
|
||||
try {
|
||||
new_data = new char[data_size];
|
||||
} catch (const std::bad_alloc&) {
|
||||
new_data = 0;
|
||||
size = 0;
|
||||
}
|
||||
|
||||
if ( 0 != new_data ) {
|
||||
std::copy( data, data + get_size(), new_data );
|
||||
std::copy( raw_data, raw_data + size, new_data + get_size() );
|
||||
@ -247,12 +237,8 @@ class section_impl : public section
|
||||
|
||||
Elf_Xword size = get_size();
|
||||
if ( 0 == data && SHT_NULL != get_type() && SHT_NOBITS != get_type() && size < get_stream_size()) {
|
||||
try {
|
||||
|
||||
data = new char[size + 1];
|
||||
} catch (const std::bad_alloc&) {
|
||||
data = 0;
|
||||
data_size = 0;
|
||||
}
|
||||
|
||||
if ( ( 0 != size ) && ( 0 != data ) ) {
|
||||
stream.seekg( (*convertor)( header.sh_offset ) );
|
||||
@ -283,12 +269,12 @@ class section_impl : public section
|
||||
|
||||
ret = inflate(&s, Z_FINISH);
|
||||
if (ret != Z_OK && ret != Z_STREAM_END){
|
||||
DEBUG_FUNCTION_LINE("NOOOO\n");
|
||||
DEBUG_FUNCTION_LINE("NOOOO");
|
||||
}
|
||||
|
||||
inflateEnd(&s);
|
||||
|
||||
free(data);
|
||||
delete [] data;
|
||||
data = uncompressedData;
|
||||
data_size = uncompressed_size;
|
||||
set_size(uncompressed_size);
|
||||
@ -301,7 +287,7 @@ class section_impl : public section
|
||||
}
|
||||
}else{
|
||||
set_size(0);
|
||||
DEBUG_FUNCTION_LINE("Failed to allocate memory.\n");
|
||||
DEBUG_FUNCTION_LINE("Failed to allocate memory.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -206,11 +206,7 @@ class segment_impl : public segment
|
||||
data = 0;
|
||||
}
|
||||
else {
|
||||
try {
|
||||
data = new char[size + 1];
|
||||
} catch (const std::bad_alloc&) {
|
||||
data = 0;
|
||||
}
|
||||
|
||||
if ( 0 != data ) {
|
||||
stream.read( data, size );
|
||||
|
Loading…
Reference in New Issue
Block a user