MCPcopy Create free account
hub / github.com/DentonW/DevIL / jas_stream_initbuf

Function jas_stream_initbuf

DevIL/src-IL/src/il_jp2.cpp:435–463  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

433// since they are designed to be used within JasPer only.
434
435static void jas_stream_initbuf(jas_stream_t *stream, int bufmode )
436{
437 /* If this function is being called, the buffer should not have been
438 initialized yet. */
439 assert(!stream->bufbase_);
440
441 if (bufmode != JAS_STREAM_UNBUF) {
442 /* The full- or line-buffered mode is being employed. */
443 if ((stream->bufbase_ = (unsigned char*)jas_malloc(JAS_STREAM_BUFSIZE +
444 JAS_STREAM_MAXPUTBACK))) {
445 stream->bufmode_ |= JAS_STREAM_FREEBUF;
446 stream->bufsize_ = JAS_STREAM_BUFSIZE;
447 } else {
448 /* The buffer allocation has failed. Resort to unbuffered
449 operation. */
450 stream->bufbase_ = stream->tinybuf_;
451 stream->bufsize_ = 1;
452 }
453 } else {
454 /* The unbuffered mode is being employed. */
455 /* Use a trivial one-character buffer. */
456 stream->bufbase_ = stream->tinybuf_;
457 stream->bufsize_ = 1;
458 }
459 stream->bufstart_ = &stream->bufbase_[JAS_STREAM_MAXPUTBACK];
460 stream->ptr_ = stream->bufstart_;
461 stream->cnt_ = 0;
462 stream->bufmode_ |= bufmode & JAS_STREAM_BUFMODEMASK;
463}
464
465static jas_stream_t *jas_stream_create()
466{

Callers 2

iJp2ReadStreamFunction · 0.85
iJp2WriteStreamFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected