ossp-pkg/sio/al.c 1.10 -> 1.11
--- al.c 2002/10/16 07:59:00 1.10
+++ al.c 2002/10/16 09:28:17 1.11
@@ -673,15 +673,26 @@
ins = cur;
/*
- * if the first chunk is not removed completely it needs to be
- * split into two halves to allow insertion of new chunks later
- * from nal
+ * the inseration point is either behind the list or
+ * within the current chunk
+ *
+ * if it is behind the list:
+ * -> insert operation switches to append mode
+ *
+ * if the insertion point is at the beginning of the current chunk:
+ * -> insertion point moves later if the chunk is removed
+ *
+ * if the inseration point is in the middle of the current chunk:
+ * -> chunk is split into two so that the insertion
+ * point is at the beginning of the second part
+ *
+ * insertion point cannot be at EOD of the chunk
*
* splitting at this point preserves all data in case the
* allocation of the split buffer fails
*/
if (doinsert) {
- if (ins != NULL && skip > 0 && skip+n < AL_CHUNK_LEN(ins)) {
+ if (ins != NULL && skip > 0) {
rc = split_chunk(al, ins, skip, &splitbuf);
if (rc != AL_OK) return AL_RC(rc);
INSERT(al,chunks,ins,splitbuf);
@@ -760,11 +771,11 @@
REMOVE(al, chunks, cur);
/*
- * when the insertion point is removed, we have to adjust
+ * when the insertion chunk is removed, we have to adjust
* the insertion point
*
- * if the insertion point was the last chunk we get a NULL
- * next pointer and the insertion method switches to APPEND
+ * if the insertion chunk was the last chunk we get a NULL
+ * next pointer and the insertion method switches to append
* mode
*/
if (cur == ins)
|
|