aboutsummaryrefslogblamecommitdiffstats
path: root/shiftbuffer.c
blob: 6a1213e4f5c6c9f586f629244edce8a68e08bcfc (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16















                                                                                     
/* See LICENSE file for copyright and license details. */
#include "common.h"


void
shiftbuffer(struct algorithm *algorithms, size_t nalgorithms, struct buffer *buffer)
{
	size_t i, consumed = SIZE_MAX;
	for (i = 0; i < nalgorithms; i++)
		consumed = MIN(consumed, algorithms[i].offset);
	if (!consumed)
		return;
	for (i = 0; i < nalgorithms; i++)
		algorithms[i].offset -= consumed;
	memmove(&buffer->buf[0], &buffer->buf[consumed], buffer->length -= consumed);
}