[nio-cvs] r52 - branches/home/psmith/restructure/src/buffer

psmith at common-lisp.net psmith at common-lisp.net
Thu Jan 25 03:38:11 UTC 2007


Author: psmith
Date: Wed Jan 24 22:38:10 2007
New Revision: 52

Modified:
   branches/home/psmith/restructure/src/buffer/buffer.lisp
Log:
added copy-buffer test

Modified: branches/home/psmith/restructure/src/buffer/buffer.lisp
==============================================================================
--- branches/home/psmith/restructure/src/buffer/buffer.lisp	(original)
+++ branches/home/psmith/restructure/src/buffer/buffer.lisp	Wed Jan 24 22:38:10 2007
@@ -103,7 +103,7 @@
 
 (defmethod print-object ((byte-buffer byte-buffer) stream)
   (with-slots (capacity position limit buf) byte-buffer
-    (format stream "<byte-buffer :capacity ~A :position ~A :limit ~A :buf ~%~A>~%" capacity position limit (if buf (pretty-hex-dump (cffi:pointer-address buf) limit) nil))))
+    (format stream "<byte-buffer :capacity ~A :position ~A :limit ~A :buf ~%~A>~%" capacity position limit (if buf (hex-dump-memory (cffi:pointer-address buf) limit) nil))))
 
 (defmethod free-buffer((byte-buffer byte-buffer))
   (with-slots (capacity position limit buf) byte-buffer
@@ -180,7 +180,9 @@
 
 (defmethod copy-buffer ((old byte-buffer) (new byte-buffer))
   (assert (<= (buffer-capacity old) (buffer-capacity new)))
-  (%memcpy (buffer-buf new) (buffer-buf old) (buffer-capacity old)))
+  (%memcpy (buffer-buf new) (buffer-buf old) (buffer-capacity old))
+  (setf (buffer-position new) (buffer-position old))
+  (setf (buffer-limit new) (buffer-limit old)))
 
 ;void *memcpy(void *dest, const void *src, size_t n);
 (cffi:defcfun ("memcpy" %memcpy) :pointer
@@ -205,8 +207,8 @@
  (%memset (buffer-buf mybuf) 78 4)
 
     (format t "Mybuf (after memset): ~A~%" mybuf)
-;    (flip mybuf)
-;    (format t "Mybuf (after flip): ~A~%" mybuf)
+    (flip mybuf)
+    (format t "Mybuf (after flip): ~A~%" mybuf)
 
 
     (format t "Remaining ~A~%" (remaining mybuf))



More information about the Nio-cvs mailing list