2 functions were added, to fasten buffer transfers:

void cio_read_to_buf(unsigned char* buf, int n)
void cio_write_from_buf(unsigned char* buf, int n)
Code written by Glenn Pearson
This commit is contained in:
Francois-Olivier Devaux 2005-05-23 15:26:29 +00:00
parent eae26f958e
commit d54925f777
1 changed files with 27 additions and 0 deletions

View File

@ -26,6 +26,7 @@
#include "cio.h"
#include <setjmp.h>
#include <memory.h>
static unsigned char *cio_start; /* pointer to the start of the stream */
static unsigned char *cio_end; /* pointer to the end of the stream */
@ -150,3 +151,29 @@ void cio_skip(int n)
{
cio_bp += n;
}
/*
* Read n bytes, copy to buffer
*
* n : number of bytes to transfer
*/
void cio_read_to_buf(unsigned char* dest_buf, int n)/* Glenn adds */
{
if (cio_bp + n > cio_end)
longjmp(j2k_error, 1);
memcpy(cio_bp, dest_buf, n);
cio_bp += n;
}
/*
* Write n bytes, copy from buffer
*
* n : number of bytes to transfer
*/
void cio_write_from_buf(unsigned char* src_buf, int n)/* Glenn adds */
{
if (cio_bp + n > cio_end)
longjmp(j2k_error, 1);
memcpy(src_buf, cio_bp, n);
cio_bp += n;
}