[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Cvs-cvs] ccvs/src ChangeLog rcs.c
From: |
Derek Robert Price |
Subject: |
[Cvs-cvs] ccvs/src ChangeLog rcs.c |
Date: |
Wed, 06 Sep 2006 15:20:18 +0000 |
CVSROOT: /cvsroot/cvs
Module name: ccvs
Changes by: Derek Robert Price <dprice> 06/09/06 15:20:18
Modified files:
src : ChangeLog rcs.c
Log message:
[bug #17560]
* rcs.c (apply_rcs_changes): Remove an unecessary memcpy. Avoid some
other processing on error.
(linevector_delete): Remove - it's no longer used.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/ChangeLog?cvsroot=cvs&r1=1.3488&r2=1.3489
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/rcs.c?cvsroot=cvs&r1=1.377&r2=1.378
Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/ChangeLog,v
retrieving revision 1.3488
retrieving revision 1.3489
diff -u -b -r1.3488 -r1.3489
--- ChangeLog 6 Sep 2006 07:49:52 -0000 1.3488
+++ ChangeLog 6 Sep 2006 15:20:17 -0000 1.3489
@@ -1,3 +1,10 @@
+2006-09-06 Derek Price <address@hidden>
+
+ [bug #17560]
+ * rcs.c (apply_rcs_changes): Remove an unecessary memcpy. Avoid some
+ other processing on error.
+ (linevector_delete): Remove - it's no longer used.
+
2006-09-06 Mark D. Baushke <address@hidden>
[bug #17560]
Index: rcs.c
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/rcs.c,v
retrieving revision 1.377
retrieving revision 1.378
diff -u -b -r1.377 -r1.378
--- rcs.c 6 Sep 2006 07:49:52 -0000 1.377
+++ rcs.c 6 Sep 2006 15:20:17 -0000 1.378
@@ -7320,28 +7320,6 @@
-/* Remove NLINES lines from VEC at position POS (where line 0 is the
- first line). */
-static void
-linevector_delete (struct linevector *vec, unsigned int pos,
- unsigned int nlines)
-{
- unsigned int i;
- unsigned int last;
-
- last = vec->nlines - nlines;
- for (i = pos; i < pos + nlines; ++i)
- {
- if (--vec->vector[i]->refcount == 0)
- free (vec->vector[i]);
- }
- for (i = pos; i < last; ++i)
- vec->vector[i] = vec->vector[i + nlines];
- vec->nlines -= nlines;
-}
-
-
-
/* Copy FROM to TO, copying the vectors but not the lines pointed to. */
static void
linevector_copy (struct linevector *to, struct linevector *from)
@@ -7546,6 +7524,11 @@
original items. */
unsigned long deltaend;
+ /* Once an error is encountered, just free the rest of the list and
+ * return.
+ */
+ if (!err)
+ {
for (deltaend = df->pos - offset;
lastmodline < deltaend;
lastmodline++)
@@ -7555,10 +7538,6 @@
orig_lines->vector[lastmodline + offset];
}
- /* Once an error is encountered, just free the rest of the list and
- * return.
- */
- if (!err)
switch (df->type)
{
case FRAG_ADD:
@@ -7615,10 +7594,9 @@
/* For each line we add the offset between the #'s
increases. */
offset--;
-
}
-
break;
+
case FRAG_DELETE:
/* we are removing this many lines from the source. */
offset += df->nlines;
@@ -7639,33 +7617,37 @@
}
break;
}
+ }
df = df->next;
free (dfhead);
dfhead = df;
}
+ if (err)
+ {
+ /* No reason to try and move a half-mutated and known invalid
+ * text into the output buffer.
+ */
+ free (lines->vector);
+ }
+ else
+ {
/* add the rest of the remaining lines to the data vector */
- for (; lastmodline < numlines; lastmodline++) {
+ for (; lastmodline < numlines; lastmodline++)
+ {
/* we need to copy from the orig structure into new one */
- lines->vector[lastmodline] = orig_lines->vector[lastmodline + offset];
+ lines->vector[lastmodline] = orig_lines->vector[lastmodline
+ + offset];
}
- /* we didn't make the lines structure fully -- so we can't
- use the linevector_copy without issues -- so we do it inline
- make the original vector larger if necessary */
- if (numlines > orig_lines->nlines)
- {
- orig_lines->vector = xnrealloc (orig_lines->vector,
- numlines,
- sizeof (*orig_lines->vector));
+ /* Move the lines vector to the original structure for output. */
+ free (orig_lines->vector);
+ orig_lines->vector = lines->vector;
orig_lines->lines_alloced = numlines;
- }
- memcpy (orig_lines->vector, lines->vector,
- xtimes (lines->nlines, sizeof (*orig_lines->vector)));
orig_lines->nlines = lines->nlines;
+ }
- free (lines->vector);
free (lines); /* we don't need it any longer */
return !err;