deps/libcows/buffers.c
void cbuf_chain_advance_read_ptr(cbuf_chain *chain, size_t consume) {
    chain->data_size -= consume;
    while(consume) {
        cbuf *cb = STAILQ_FIRST(&chain->head);
        size_t avail = cb->write_offset - cb->read_offset;
        if(avail >= consume) {
            cb->read_offset += consume;
            if(cb->read_offset == cb->write_offset)
                cb->read_offset = cb->write_offset = cb->buf;
            break;
        } else {
            assert(STAILQ_NEXT(cb, next));
            STAILQ_REMOVE_HEAD(&chain->head, next);
            consume -= avail;
            if(cb->free) cb->free(cb->buf);
            free(cb);
        }
    }
}
/*
 * Remove the (consumed) number of bytes out of the head of the chain.
 */
Remove the (consumed) number of bytes out of the head of the chain.
Remove the ( consumed ) number of bytes out of the head of the chain .
void cbuf_chain_advance_read_ptr(cbuf_chain *chain, size_t consume) {
    chain->data_size -= consume;
    while(consume) {
        cbuf *cb = STAILQ_FIRST(&chain->head);
        size_t avail = cb->write_offset - cb->read_offset;
        if(avail >= consume) {
            cb->read_offset += consume;
            if(cb->read_offset == cb->write_offset)
                cb->read_offset = cb->write_offset = cb->buf;
            break;
        } else {
            assert(STAILQ_NEXT(cb, next));
            STAILQ_REMOVE_HEAD(&chain->head, next);
            consume -= avail;
            if(cb->free) cb->free(cb->buf);
            free(cb);
        }
    }
}
void cbuf_chain_advance_read_ptr ( cbuf_chain * chain , size_t consume ) { chain -> data_size -= consume ; while ( consume ) { cbuf * cb = STAILQ_FIRST ( & chain -> head ) ; size_t avail = cb -> write_offset - cb -> read_offset ; if ( avail >= consume ) { cb -> read_offset += consume ; if ( cb -> read_offset == cb -> write_offset ) cb -> read_offset = cb -> write_offset = cb -> buf ; break ; } else { assert ( STAILQ_NEXT ( cb , next ) ) ; STAILQ_REMOVE_HEAD ( & chain -> head , next ) ; consume -= avail ; if ( cb -> free ) cb -> free ( cb -> buf ) ; free ( cb ) ; } } }
Remove the (consumed) number of bytes out of the head of the chain.
Remove the ( consumed ) number of bytes out of the head of the chain .