diff options
| author | Francois-Olivier Devaux <fodevaux@users.noreply.github.com> | 2005-05-23 15:26:29 +0000 |
|---|---|---|
| committer | Francois-Olivier Devaux <fodevaux@users.noreply.github.com> | 2005-05-23 15:26:29 +0000 |
| commit | d54925f777745b0f9389dfed90136088d84dc38b (patch) | |
| tree | 6ee0c64a78cfed87447b44999fcf6e99fc015fba /libopenjpeg/cio.c | |
| parent | eae26f958e024bcb78fbed61b0affe058861ac61 (diff) | |
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
Diffstat (limited to 'libopenjpeg/cio.c')
| -rw-r--r-- | libopenjpeg/cio.c | 27 |
1 files changed, 27 insertions, 0 deletions
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 <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; +}
\ No newline at end of file |
