--- al.c 2002/10/14 15:26:04 1.6
+++ al.c 2002/10/14 15:41:37 1.7
@@ -615,8 +615,14 @@
}
/*
+ * this is the central function to manipulate assembly lists
*
+ * cut arbitrary spans from list into a destination buffer (or drop it)
+ * insert (destructive move) content from another list into the cut
*
+ * this is analog to perls splice function, except that
+ * -> the output is not stored in the target buffer but is appended
+ * -> the replacement data is moved and not copied.
*
*/
al_rc_t al_splice(al_t *al, size_t off, size_t n, al_t *nal, al_t *tal)
@@ -889,6 +895,32 @@
if (rc != AL_ERR_EOF)
return rc;
+
+ return AL_OK;
+}
+
+/*
+ * full list traversal with data copy to target assembly list
+ *
+ * traversal context is kept on stack (XXX ?)
+ */
+al_rc_t al_copy(al_t *al, size_t off, size_t n, al_t *tal)
+{
+ al_rc_t rc;
+ al_tx_t tx; /* XXX - private tx structure on stack */
+ al_chunk_t *view;
+ size_t step;
+
+ rc = al_traverse(al, off, n, AL_FORWARD, &tx);
+ if (rc != AL_OK) return rc;
+
+ while ((rc = al_traverse_next(al, &tx, &view)) == AL_OK) {
+ step = AL_CHUNK_LEN(view);
+ al_append_bytes(tal, AL_CHUNK_PTR(view,0), step);
+ }
+
+ if (rc != AL_ERR_EOF)
+ return rc;
return AL_OK;
}
|