apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Querna <c...@force-elite.com>
Subject apr_brigade_move
Date Mon, 25 Apr 2005 18:13:31 GMT
I have used this code in several places, just copying and pasting it
around.  I think it is a good candidate for putting it, or something
like it, into apr_util.

/**
 * Move the contents of source, after point e, to dest.
 * @param dest The destination Brigade
 * @param source The Source Brigade
 * @param point The point in the Source Brigade to start moving from.
 */
static void apr_brigade_move(apr_bucket_brigade *dest,
                             apr_bucket_brigade *source,
                             apr_bucket *point)
{
    apr_bucket *f;

    if (e != APR_BRIGADE_SENTINEL(source)) {
        f = APR_RING_LAST(&source->list);
        APR_RING_UNSPLICE(point, f, link);
        APR_RING_SPLICE_HEAD(&dest->list, point, f, apr_bucket, link);
    }

    APR_BRIGADE_CHECK_CONSISTENCY(dest);
    APR_BRIGADE_CHECK_CONSISTENCY(source);
}


Another thing to consider is naming it 'apr_brigade_shift_head", because
it 'shifts' all of the buckets from source onto the head of the
destination.  Then you could have an 'apr_brigade_shift_tail'... etc.

Comments?

-Paul

Mime
View raw message