| 713 | } |
| 714 | |
| 715 | void loadStreamMemory( IStreamRef is, std::shared_ptr<uint8_t> *resultData, size_t *resultDataSize ) |
| 716 | { |
| 717 | // prevent crash if stream is not valid |
| 718 | if( ! is ) |
| 719 | throw StreamExc(); |
| 720 | |
| 721 | off_t fileSize = is->size(); |
| 722 | if( fileSize > std::numeric_limits<off_t>::max() ) |
| 723 | throw StreamExcOutOfMemory(); |
| 724 | |
| 725 | *resultData = std::shared_ptr<uint8_t>( (uint8_t*)malloc( static_cast<size_t>( fileSize ) ), free ); |
| 726 | if( ! (*resultData ) ) |
| 727 | throw StreamExcOutOfMemory(); |
| 728 | |
| 729 | *resultDataSize = static_cast<size_t>( fileSize ); |
| 730 | is->readDataAvailable( resultData->get(), static_cast<size_t>( fileSize ) ); |
| 731 | } |
| 732 | |
| 733 | BufferRef loadStreamBuffer( IStreamRef is ) |
| 734 | { |
nothing calls this directly
no test coverage detected