MCPcopy Create free account
hub / github.com/LibRaw/LibRaw / open_buffer

Method open_buffer

src/utils/open.cpp:221–260  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

219#endif
220
221int LibRaw::open_buffer(const void *buffer, size_t size)
222{
223 // this stream will close on recycle()
224 if (!buffer || buffer == (const void *)-1)
225 return LIBRAW_IO_ERROR;
226
227 if ((size > (INT64)LIBRAW_MAX_DNG_RAW_FILE_SIZE)
228 && (size > (INT64)LIBRAW_MAX_NONDNG_RAW_FILE_SIZE)
229 && (size > (INT64)LIBRAW_MAX_CR3_RAW_FILE_SIZE)
230 )
231 return LIBRAW_TOO_BIG;
232
233 LibRaw_buffer_datastream *stream;
234 try
235 {
236 stream = new LibRaw_buffer_datastream(buffer, size);
237 }
238 catch (const std::bad_alloc& )
239 {
240 recycle();
241 return LIBRAW_UNSUFFICIENT_MEMORY;
242 }
243 if (!stream->valid())
244 {
245 delete stream;
246 return LIBRAW_IO_ERROR;
247 }
248 ID.input_internal = 0; // preserve from deletion on error
249 int ret = open_datastream(stream);
250 if (ret == LIBRAW_SUCCESS)
251 {
252 ID.input_internal = 1; // flag to delete datastream on recycle
253 }
254 else
255 {
256 delete stream;
257 ID.input_internal = 0;
258 }
259 return ret;
260}
261
262int LibRaw::open_bayer(const unsigned char *buffer, unsigned datalen,
263 ushort _raw_width, ushort _raw_height,

Callers 2

mainFunction · 0.80
libraw_open_bufferFunction · 0.80

Calls 1

validMethod · 0.45

Tested by

no test coverage detected