From d54925f777745b0f9389dfed90136088d84dc38b Mon Sep 17 00:00:00 2001 From: Francois-Olivier Devaux Date: Mon, 23 May 2005 15:26:29 +0000 Subject: [PATCH] 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 --- libopenjpeg/cio.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/libopenjpeg/cio.c b/libopenjpeg/cio.c index 7aecffca..631e6ae6 100644 --- a/libopenjpeg/cio.c +++ b/libopenjpeg/cio.c @@ -26,6 +26,7 @@ #include "cio.h" #include +#include 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; +} \ No newline at end of file