mirror of
https://github.com/libevent/libevent.git
synced 2025-01-09 00:56:20 +08:00
Use the free-trailing-chains function in evbuffer_insert_chain too
This commit is contained in:
parent
c37069cd79
commit
b18c04dd74
20
buffer.c
20
buffer.c
@ -290,21 +290,11 @@ evbuffer_chain_insert(struct evbuffer *buf,
|
||||
EVUTIL_ASSERT(buf->first == NULL);
|
||||
buf->first = buf->last = chain;
|
||||
} else {
|
||||
struct evbuffer_chain **ch = buf->last_with_datap;
|
||||
/* Find the first victim chain. It might be *last_with_datap */
|
||||
while ((*ch) && ((*ch)->off != 0 || CHAIN_PINNED(*ch)))
|
||||
ch = &(*ch)->next;
|
||||
if (*ch == NULL) {
|
||||
/* There is no victim; just append this new chain. */
|
||||
buf->last->next = chain;
|
||||
if (chain->off)
|
||||
buf->last_with_datap = &buf->last->next;
|
||||
} else {
|
||||
/* Replace all victim chains with this chain. */
|
||||
EVUTIL_ASSERT(evbuffer_chains_all_empty(*ch));
|
||||
evbuffer_free_all_chains(*ch);
|
||||
*ch = chain;
|
||||
}
|
||||
struct evbuffer_chain **chp;
|
||||
chp = evbuffer_free_trailing_empty_chains(buf);
|
||||
*chp = chain;
|
||||
if (chain->off)
|
||||
buf->last_with_datap = chp;
|
||||
buf->last = chain;
|
||||
}
|
||||
buf->total_len += chain->off;
|
||||
|
Loading…
x
Reference in New Issue
Block a user