2 functions were added, to fasten buffer transfers:
authorFrancois-Olivier Devaux <fodevaux@users.noreply.github.com>
Mon, 23 May 2005 15:26:29 +0000 (15:26 +0000)
committerFrancois-Olivier Devaux <fodevaux@users.noreply.github.com>
Mon, 23 May 2005 15:26:29 +0000 (15:26 +0000)
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

index 7aecffca8c9e030545068df0277e857b756589c7..631e6ae6f208b830d0f8e604157624a264048c91 100644 (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;
+}
\ No newline at end of file