Changed names for mem block read/write functions.
Fri Sep 26 22:54:04 PDT 2008 mail@chaitanyagupta.com
* Changed names for mem block read/write functions.
diff -rN -u old-cl-bzip2/bzip2.lisp new-cl-bzip2/bzip2.lisp
--- old-cl-bzip2/bzip2.lisp 2014-07-27 21:15:04.000000000 -0700
+++ new-cl-bzip2/bzip2.lisp 2014-07-27 21:15:04.000000000 -0700
@@ -227,20 +227,22 @@
(deftype octet-vector ()
'(vector (unsigned-byte 8)))
-;;; High level stuff
+;;; Block read/write from C memory
-(defparameter *input-chunk-size* 4096)
-(defparameter *output-chunk-size* 4096)
-
-(defun write-to-lisp-stream (ptr stream length)
+(defun mem-read-stream (stream ptr length)
(loop
for i from 0 to (1- length)
do (write-byte (mem-aref ptr :uchar i) stream)))
-(defun vector->cvector-copy (vector cptr &optional (start 0) (end (length vector)))
+(defun mem-write-vector (vector ptr &optional (count (length vector)))
(loop
- for i from start to (1- end)
- do (setf (mem-aref cptr :uchar i) (aref vector i))))
+ for i below count
+ do (setf (mem-aref ptr :uchar i) (aref vector i))))
+
+;;; High level stuff
+
+(defparameter *input-chunk-size* 4096)
+(defparameter *output-chunk-size* 4096)
(defstruct (array-container
(:constructor make-array-container-aux)
@@ -281,7 +283,7 @@
(in-cvec (in-cvec ac))
(out-cvec (out-cvec ac))
(input-left-p (= in-size input-chunk-size)))
- (vector->cvector-copy in-vec in-cvec 0 in-size)
+ (mem-write-vector in-vec in-cvec in-size)
(with-foreign-slots ((next-in avail-in next-out avail-out) bz-stream bz-stream)
(setf next-in in-cvec
avail-in in-size)
@@ -296,7 +298,7 @@
(bz-compress bz-stream +bz-run+)
(when (< avail-out output-chunk-size)
;; Writing to output stream
- (write-to-lisp-stream out-cvec out-stream (- output-chunk-size avail-out)))
+ (mem-read-stream out-stream out-cvec (- output-chunk-size avail-out)))
(when (= avail-in 0)
(return-from run nil))))
;; Using action BZ_FINISH, only if no more input is left
@@ -310,7 +312,7 @@
(bz-compress bz-stream +bz-finish+)))
(when (< avail-out output-chunk-size)
;; Writing to output stream
- (write-to-lisp-stream out-cvec out-stream (- output-chunk-size avail-out)))
+ (mem-read-stream out-stream out-cvec (- output-chunk-size avail-out)))
(when (= return-code +bz-stream-end+)
(return-from finish nil)))))))
(force-output out-stream)
@@ -394,7 +396,7 @@
(in-cvec (in-cvec ac))
(out-cvec (out-cvec ac))
(input-left-p (= in-size input-chunk-size)))
- (vector->cvector-copy in-vec in-cvec 0 in-size)
+ (mem-write-vector in-vec in-cvec in-size)
(with-foreign-slots ((next-in avail-in next-out avail-out) bz-stream bz-stream)
(setf next-in in-cvec
avail-in in-size)
@@ -405,7 +407,7 @@
avail-out output-chunk-size)
(let ((return-code (bz-decompress bz-stream)))
(when (< avail-out output-chunk-size)
- (write-to-lisp-stream out-cvec out-stream (- output-chunk-size avail-out)))
+ (mem-read-stream out-stream out-cvec (- output-chunk-size avail-out)))
(when (or (= avail-in 0)
(= return-code +bz-stream-end+))
(return-from decompress nil)))))