While the handrolled version works in this case it thrashes the TAILQ
and sets a bad example.
OK?

diff --git a/buffer.c b/buffer.c
index 0b590eb..440d9f0 100644
--- a/buffer.c
+++ b/buffer.c
@@ -153,7 +153,7 @@ killbuffer(struct buffer *bp)
        struct buffer *bp2;
        struct mgwin  *wp;
        int s;
-       struct undo_rec *rec, *next;
+       struct undo_rec *rec;
 
        /*
         * Find some other buffer to display. Try the alternate buffer,
@@ -204,12 +204,10 @@ killbuffer(struct buffer *bp)
                        bp1->b_altb = (bp->b_altb == bp1) ? NULL : bp->b_altb;
                bp1 = bp1->b_bufp;
        }
-       rec = TAILQ_FIRST(&bp->b_undo);
 
-       while (rec != NULL) {
-               next = TAILQ_NEXT(rec, next);
+       while ((rec = TAILQ_FIRST(&curbp->b_undo))) {
+               TAILQ_REMOVE(&curbp->b_undo, rec, next);
                free_undo_record(rec);
-               rec = next;
        }
 
        free(bp->b_bname);                      /* Release name block    */

-- 
I'm not entirely sure you are real.

Reply via email to