Skip to content

Commit

Permalink
jp2: remove use of uchar define from older jasPer
Browse files Browse the repository at this point in the history
fixes DentonW#41
jasPer now defines jas_uchar instead of uchar, but it's a moot
point since the offending code in DevIL was never executed and could
be removed.
  • Loading branch information
bcampbell committed Nov 16, 2016
1 parent f8fc86c commit 8b5e3cb
Showing 1 changed file with 14 additions and 28 deletions.
42 changes: 14 additions & 28 deletions DevIL/src-IL/src/il_jp2.c
Expand Up @@ -358,7 +358,7 @@ static jas_stream_ops_t jas_stream_devilops = {

static jas_stream_t *jas_stream_create(void);
static void jas_stream_destroy(jas_stream_t *stream);
static void jas_stream_initbuf(jas_stream_t *stream, int bufmode, char *buf, int bufsize);
static void jas_stream_initbuf(jas_stream_t *stream, int bufmode );


// Modified version of jas_stream_fopen and jas_stream_memopen from jas_stream.c of JasPer
Expand All @@ -377,7 +377,7 @@ jas_stream_t *iJp2ReadStream()
stream->openmode_ = JAS_STREAM_READ | JAS_STREAM_BINARY;

/* We use buffering whether it is from memory or a file. */
jas_stream_initbuf(stream, JAS_STREAM_FULLBUF, 0, 0);
jas_stream_initbuf(stream, JAS_STREAM_FULLBUF);

/* Select the operations for a memory stream. */
stream->ops_ = &jas_stream_devilops;
Expand Down Expand Up @@ -432,40 +432,26 @@ jas_stream_t *iJp2ReadStream()
// The following functions are taken directly from jas_stream.c of JasPer,
// since they are designed to be used within JasPer only.

static void jas_stream_initbuf(jas_stream_t *stream, int bufmode, char *buf,
int bufsize)
static void jas_stream_initbuf(jas_stream_t *stream, int bufmode )
{
/* If this function is being called, the buffer should not have been
initialized yet. */
assert(!stream->bufbase_);

if (bufmode != JAS_STREAM_UNBUF) {
/* The full- or line-buffered mode is being employed. */
if (!buf) {
/* The caller has not specified a buffer to employ, so allocate
one. */
if ((stream->bufbase_ = jas_malloc(JAS_STREAM_BUFSIZE +
JAS_STREAM_MAXPUTBACK))) {
stream->bufmode_ |= JAS_STREAM_FREEBUF;
stream->bufsize_ = JAS_STREAM_BUFSIZE;
} else {
/* The buffer allocation has failed. Resort to unbuffered
operation. */
stream->bufbase_ = stream->tinybuf_;
stream->bufsize_ = 1;
}
} else {
/* The caller has specified a buffer to employ. */
/* The buffer must be large enough to accommodate maximum
putback. */
assert(bufsize > JAS_STREAM_MAXPUTBACK);
stream->bufbase_ = JAS_CAST(uchar *, buf);
stream->bufsize_ = bufsize - JAS_STREAM_MAXPUTBACK;
}
if ((stream->bufbase_ = jas_malloc(JAS_STREAM_BUFSIZE +
JAS_STREAM_MAXPUTBACK))) {
stream->bufmode_ |= JAS_STREAM_FREEBUF;
stream->bufsize_ = JAS_STREAM_BUFSIZE;
} else {
/* The buffer allocation has failed. Resort to unbuffered
operation. */
stream->bufbase_ = stream->tinybuf_;
stream->bufsize_ = 1;
}
} else {
/* The unbuffered mode is being employed. */
/* A buffer should not have been supplied by the caller. */
assert(!buf);
/* Use a trivial one-character buffer. */
stream->bufbase_ = stream->tinybuf_;
stream->bufsize_ = 1;
Expand Down Expand Up @@ -527,7 +513,7 @@ jas_stream_t *iJp2WriteStream()
stream->openmode_ = JAS_STREAM_WRITE | JAS_STREAM_BINARY;

/* We use buffering whether it is from memory or a file. */
jas_stream_initbuf(stream, JAS_STREAM_FULLBUF, 0, 0);
jas_stream_initbuf(stream, JAS_STREAM_FULLBUF);

/* Select the operations for a memory stream. */
stream->ops_ = &jas_stream_devilops;
Expand Down

0 comments on commit 8b5e3cb

Please sign in to comment.