mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 14:21:25 +02:00
CLEANUP: buffers: Remove buffer_bounce_realign function
Not used anymore since last commit.
This commit is contained in:
parent
533182f1c8
commit
aaf4a325ca
@ -57,7 +57,6 @@ int buffer_replace2(struct buffer *b, char *pos, char *end, const char *str, int
|
|||||||
int buffer_insert_line2(struct buffer *b, char *pos, const char *str, int len);
|
int buffer_insert_line2(struct buffer *b, char *pos, const char *str, int len);
|
||||||
void buffer_dump(FILE *o, struct buffer *b, int from, int to);
|
void buffer_dump(FILE *o, struct buffer *b, int from, int to);
|
||||||
void buffer_slow_realign(struct buffer *buf);
|
void buffer_slow_realign(struct buffer *buf);
|
||||||
void buffer_bounce_realign(struct buffer *buf);
|
|
||||||
|
|
||||||
/*****************************************************************/
|
/*****************************************************************/
|
||||||
/* These functions are used to compute various buffer area sizes */
|
/* These functions are used to compute various buffer area sizes */
|
||||||
|
63
src/buffer.c
63
src/buffer.c
@ -176,69 +176,6 @@ void buffer_slow_realign(struct buffer *buf)
|
|||||||
buf->p = buf->data;
|
buf->p = buf->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Realigns a possibly non-contiguous buffer by bouncing bytes from source to
|
|
||||||
* destination. It does not use any intermediate buffer and does the move in
|
|
||||||
* place, though it will be slower than a simple memmove() on contiguous data,
|
|
||||||
* so it's desirable to use it only on non-contiguous buffers. No pointers are
|
|
||||||
* changed, the caller is responsible for that.
|
|
||||||
*/
|
|
||||||
void buffer_bounce_realign(struct buffer *buf)
|
|
||||||
{
|
|
||||||
int advance, to_move;
|
|
||||||
char *from, *to;
|
|
||||||
|
|
||||||
from = bo_ptr(buf);
|
|
||||||
advance = buf->data + buf->size - from;
|
|
||||||
if (!advance)
|
|
||||||
return;
|
|
||||||
|
|
||||||
to_move = buffer_len(buf);
|
|
||||||
while (to_move) {
|
|
||||||
char last, save;
|
|
||||||
|
|
||||||
last = *from;
|
|
||||||
to = from + advance;
|
|
||||||
if (to >= buf->data + buf->size)
|
|
||||||
to -= buf->size;
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
save = *to;
|
|
||||||
*to = last;
|
|
||||||
last = save;
|
|
||||||
to_move--;
|
|
||||||
if (!to_move)
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* check if we went back home after rotating a number of bytes */
|
|
||||||
if (to == from)
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* if we ended up in the empty area, let's walk to next place. The
|
|
||||||
* empty area is either between buf->r and from or before from or
|
|
||||||
* after buf->r.
|
|
||||||
*/
|
|
||||||
if (from > bi_end(buf)) {
|
|
||||||
if (to >= bi_end(buf) && to < from)
|
|
||||||
break;
|
|
||||||
} else if (from < bi_end(buf)) {
|
|
||||||
if (to < from || to >= bi_end(buf))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* we have overwritten a byte of the original set, let's move it */
|
|
||||||
to += advance;
|
|
||||||
if (to >= buf->data + buf->size)
|
|
||||||
to -= buf->size;
|
|
||||||
}
|
|
||||||
|
|
||||||
from++;
|
|
||||||
if (from >= buf->data + buf->size)
|
|
||||||
from -= buf->size;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Dumps part or all of a buffer.
|
* Dumps part or all of a buffer.
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user