mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-08 11:53:00 -04:00
Do not use evbuffer_expand() to add the first chain to a buffer
(It's a big function, and using it this way is overkill.)
This commit is contained in:
parent
2014ae4ac6
commit
5c0ebb33f4
11
buffer.c
11
buffer.c
@ -1310,9 +1310,10 @@ evbuffer_add(struct evbuffer *buf, const void *data_in, size_t datlen)
|
||||
/* If there are no chains allocated for this buffer, allocate one
|
||||
* big enough to hold all the data. */
|
||||
if (chain == NULL) {
|
||||
if (evbuffer_expand(buf, datlen) == -1)
|
||||
chain = evbuffer_chain_new(datlen);
|
||||
if (!chain)
|
||||
goto done;
|
||||
chain = buf->last;
|
||||
evbuffer_chain_insert(buf, chain);
|
||||
}
|
||||
|
||||
if ((chain->flags & EVBUFFER_IMMUTABLE) == 0) {
|
||||
@ -1389,10 +1390,10 @@ evbuffer_prepend(struct evbuffer *buf, const void *data, size_t datlen)
|
||||
chain = buf->first;
|
||||
|
||||
if (chain == NULL) {
|
||||
if (evbuffer_expand(buf, datlen) == -1)
|
||||
chain = evbuffer_chain_new(datlen);
|
||||
if (!chain)
|
||||
goto done;
|
||||
chain = buf->first;
|
||||
chain->misalign = chain->buffer_len;
|
||||
evbuffer_chain_insert(buf, chain);
|
||||
}
|
||||
|
||||
/* we cannot touch immutable buffers */
|
||||
|
Loading…
x
Reference in New Issue
Block a user