• Home
  • Raw
  • Download

Lines Matching refs:chain

138 	(ptr)->internal_.chain = NULL;		\
142 static void evbuffer_chain_align(struct evbuffer_chain *chain);
143 static int evbuffer_chain_should_realign(struct evbuffer_chain *chain,
153 static inline void evbuffer_chain_incref(struct evbuffer_chain *chain);
158 struct evbuffer_chain *chain; in evbuffer_chain_new() local
177 if ((chain = mm_malloc(to_alloc)) == NULL) in evbuffer_chain_new()
180 memset(chain, 0, EVBUFFER_CHAIN_SIZE); in evbuffer_chain_new()
182 chain->buffer_len = to_alloc - EVBUFFER_CHAIN_SIZE; in evbuffer_chain_new()
187 chain->buffer = EVBUFFER_CHAIN_EXTRA(unsigned char, chain); in evbuffer_chain_new()
189 chain->refcnt = 1; in evbuffer_chain_new()
191 return (chain); in evbuffer_chain_new()
195 evbuffer_chain_free(struct evbuffer_chain *chain) in evbuffer_chain_free() argument
197 EVUTIL_ASSERT(chain->refcnt > 0); in evbuffer_chain_free()
198 if (--chain->refcnt > 0) { in evbuffer_chain_free()
203 if (CHAIN_PINNED(chain)) { in evbuffer_chain_free()
205 chain->refcnt++; in evbuffer_chain_free()
206 chain->flags |= EVBUFFER_DANGLING; in evbuffer_chain_free()
212 if (chain->flags & EVBUFFER_REFERENCE) { in evbuffer_chain_free()
216 chain); in evbuffer_chain_free()
218 (*info->cleanupfn)(chain->buffer, in evbuffer_chain_free()
219 chain->buffer_len, in evbuffer_chain_free()
222 if (chain->flags & EVBUFFER_FILESEGMENT) { in evbuffer_chain_free()
226 chain); in evbuffer_chain_free()
230 UnmapViewOfFile(chain->buffer); in evbuffer_chain_free()
235 if (chain->flags & EVBUFFER_MULTICAST) { in evbuffer_chain_free()
239 chain); in evbuffer_chain_free()
251 mm_free(chain); in evbuffer_chain_free()
255 evbuffer_free_all_chains(struct evbuffer_chain *chain) in evbuffer_free_all_chains() argument
258 for (; chain; chain = next) { in evbuffer_free_all_chains()
259 next = chain->next; in evbuffer_free_all_chains()
260 evbuffer_chain_free(chain); in evbuffer_free_all_chains()
266 evbuffer_chains_all_empty(struct evbuffer_chain *chain) in evbuffer_chains_all_empty() argument
268 for (; chain; chain = chain->next) { in evbuffer_chains_all_empty()
269 if (chain->off) in evbuffer_chains_all_empty()
277 static inline int evbuffer_chains_all_empty(struct evbuffer_chain *chain) { in evbuffer_chains_all_empty() argument
309 struct evbuffer_chain *chain) in evbuffer_chain_insert() argument
316 buf->first = buf->last = chain; in evbuffer_chain_insert()
320 *chp = chain; in evbuffer_chain_insert()
321 if (chain->off) in evbuffer_chain_insert()
323 buf->last = chain; in evbuffer_chain_insert()
325 buf->total_len += chain->off; in evbuffer_chain_insert()
331 struct evbuffer_chain *chain; in evbuffer_chain_insert_new() local
332 if ((chain = evbuffer_chain_new(datlen)) == NULL) in evbuffer_chain_insert_new()
334 evbuffer_chain_insert(buf, chain); in evbuffer_chain_insert_new()
335 return chain; in evbuffer_chain_insert_new()
339 evbuffer_chain_pin_(struct evbuffer_chain *chain, unsigned flag) in evbuffer_chain_pin_() argument
341 EVUTIL_ASSERT((chain->flags & flag) == 0); in evbuffer_chain_pin_()
342 chain->flags |= flag; in evbuffer_chain_pin_()
346 evbuffer_chain_unpin_(struct evbuffer_chain *chain, unsigned flag) in evbuffer_chain_unpin_() argument
348 EVUTIL_ASSERT((chain->flags & flag) != 0); in evbuffer_chain_unpin_()
349 chain->flags &= ~flag; in evbuffer_chain_unpin_()
350 if (chain->flags & EVBUFFER_DANGLING) in evbuffer_chain_unpin_()
351 evbuffer_chain_free(chain); in evbuffer_chain_unpin_()
355 evbuffer_chain_incref(struct evbuffer_chain *chain) in evbuffer_chain_incref() argument
357 ++chain->refcnt; in evbuffer_chain_incref()
562 struct evbuffer_chain *chain, *next; in evbuffer_decref_and_unlock_() local
572 for (chain = buffer->first; chain != NULL; chain = next) { in evbuffer_decref_and_unlock_()
573 next = chain->next; in evbuffer_decref_and_unlock_()
574 evbuffer_chain_free(chain); in evbuffer_decref_and_unlock_()
622 struct evbuffer_chain *chain; in evbuffer_get_contiguous_space() local
626 chain = buf->first; in evbuffer_get_contiguous_space()
627 result = (chain != NULL ? chain->off : 0); in evbuffer_get_contiguous_space()
673 struct evbuffer_chain *chain, **chainp; in evbuffer_reserve_space() local
682 if ((chain = evbuffer_expand_singlechain(buf, size)) == NULL) in evbuffer_reserve_space()
685 vec[0].iov_base = (void *)CHAIN_SPACE_PTR(chain); in evbuffer_reserve_space()
686 vec[0].iov_len = (size_t)CHAIN_SPACE_LEN(chain); in evbuffer_reserve_space()
722 struct evbuffer_chain *chain, **firstchainp, **chainp; in evbuffer_commit_space() local
755 chain = *firstchainp; in evbuffer_commit_space()
759 if (!chain) in evbuffer_commit_space()
761 if (vec[i].iov_base != (void *)CHAIN_SPACE_PTR(chain) || in evbuffer_commit_space()
762 (size_t)vec[i].iov_len > CHAIN_SPACE_LEN(chain)) in evbuffer_commit_space()
764 chain = chain->next; in evbuffer_commit_space()
812 struct evbuffer_chain *chain, **pinned; in PRESERVE_PINNED() local
825 chain = *first = *pinned; in PRESERVE_PINNED()
830 if (chain->off) { in PRESERVE_PINNED()
834 tmp = evbuffer_chain_new(chain->off); in PRESERVE_PINNED()
837 memcpy(tmp->buffer, chain->buffer + chain->misalign, in PRESERVE_PINNED()
838 chain->off); in PRESERVE_PINNED()
839 tmp->off = chain->off; in PRESERVE_PINNED()
842 chain->misalign += chain->off; in PRESERVE_PINNED()
843 chain->off = 0; in PRESERVE_PINNED()
906 struct evbuffer_chain *chain = src->first; in APPEND_CHAIN_MULTICAST() local
912 for (; chain; chain = chain->next) { in APPEND_CHAIN_MULTICAST()
913 if (!chain->off || chain->flags & EVBUFFER_DANGLING) { in APPEND_CHAIN_MULTICAST()
930 evbuffer_chain_incref(chain); in APPEND_CHAIN_MULTICAST()
931 extra->parent = chain; in APPEND_CHAIN_MULTICAST()
932 chain->flags |= EVBUFFER_IMMUTABLE; in APPEND_CHAIN_MULTICAST()
933 tmp->buffer_len = chain->buffer_len; in APPEND_CHAIN_MULTICAST()
934 tmp->misalign = chain->misalign; in APPEND_CHAIN_MULTICAST()
935 tmp->off = chain->off; in APPEND_CHAIN_MULTICAST()
937 tmp->buffer = chain->buffer; in APPEND_CHAIN_MULTICAST()
1010 struct evbuffer_chain *chain; in evbuffer_add_buffer_reference() local
1016 chain = inbuf->first; in evbuffer_add_buffer_reference()
1026 for (; chain; chain = chain->next) { in evbuffer_add_buffer_reference()
1027 if ((chain->flags & (EVBUFFER_FILESEGMENT|EVBUFFER_SENDFILE|EVBUFFER_MULTICAST)) != 0) { in evbuffer_add_buffer_reference()
1098 struct evbuffer_chain *chain, *next; in evbuffer_drain() local
1115 for (chain = buf->first; chain != NULL; chain = next) { in evbuffer_drain()
1116 next = chain->next; in evbuffer_drain()
1117 evbuffer_chain_free(chain); in evbuffer_drain()
1127 for (chain = buf->first; in evbuffer_drain()
1128 remaining >= chain->off; in evbuffer_drain()
1129 chain = next) { in evbuffer_drain()
1130 next = chain->next; in evbuffer_drain()
1131 remaining -= chain->off; in evbuffer_drain()
1133 if (chain == *buf->last_with_datap) { in evbuffer_drain()
1136 if (&chain->next == buf->last_with_datap) in evbuffer_drain()
1139 if (CHAIN_PINNED_R(chain)) { in evbuffer_drain()
1141 chain->misalign += chain->off; in evbuffer_drain()
1142 chain->off = 0; in evbuffer_drain()
1145 evbuffer_chain_free(chain); in evbuffer_drain()
1148 buf->first = chain; in evbuffer_drain()
1149 EVUTIL_ASSERT(chain && remaining <= chain->off); in evbuffer_drain()
1150 chain->misalign += remaining; in evbuffer_drain()
1151 chain->off -= remaining; in evbuffer_drain()
1189 struct evbuffer_chain *chain; in evbuffer_copyout_from() local
1202 chain = pos->internal_.chain; in evbuffer_copyout_from()
1207 chain = buf->first; in evbuffer_copyout_from()
1224 while (datlen && datlen >= chain->off - pos_in_chain) { in evbuffer_copyout_from()
1225 size_t copylen = chain->off - pos_in_chain; in evbuffer_copyout_from()
1227 chain->buffer + chain->misalign + pos_in_chain, in evbuffer_copyout_from()
1232 chain = chain->next; in evbuffer_copyout_from()
1234 EVUTIL_ASSERT(chain || datlen==0); in evbuffer_copyout_from()
1238 EVUTIL_ASSERT(chain); in evbuffer_copyout_from()
1239 EVUTIL_ASSERT(datlen+pos_in_chain <= chain->off); in evbuffer_copyout_from()
1241 memcpy(data, chain->buffer + chain->misalign + pos_in_chain, in evbuffer_copyout_from()
1261 struct evbuffer_chain *chain, *previous; in evbuffer_remove_buffer() local
1267 chain = previous = src->first; in evbuffer_remove_buffer()
1288 while (chain->off <= datlen) { in evbuffer_remove_buffer()
1292 EVUTIL_ASSERT(chain != *src->last_with_datap); in evbuffer_remove_buffer()
1293 nread += chain->off; in evbuffer_remove_buffer()
1294 datlen -= chain->off; in evbuffer_remove_buffer()
1295 previous = chain; in evbuffer_remove_buffer()
1296 if (src->last_with_datap == &chain->next) in evbuffer_remove_buffer()
1298 chain = chain->next; in evbuffer_remove_buffer()
1313 src->first = chain; in evbuffer_remove_buffer()
1322 evbuffer_add(dst, chain->buffer + chain->misalign, datlen); in evbuffer_remove_buffer()
1323 chain->misalign += datlen; in evbuffer_remove_buffer()
1324 chain->off -= datlen; in evbuffer_remove_buffer()
1347 struct evbuffer_chain *chain, *next, *tmp, *last_with_data; in evbuffer_pullup() local
1355 chain = buf->first; in evbuffer_pullup()
1367 if (chain->off >= (size_t)size) { in evbuffer_pullup()
1368 result = chain->buffer + chain->misalign; in evbuffer_pullup()
1373 remaining = size - chain->off; in evbuffer_pullup()
1375 for (tmp=chain->next; tmp; tmp=tmp->next) { in evbuffer_pullup()
1383 if (CHAIN_PINNED(chain)) { in evbuffer_pullup()
1384 size_t old_off = chain->off; in evbuffer_pullup()
1385 if (CHAIN_SPACE_LEN(chain) < size - chain->off) { in evbuffer_pullup()
1389 buffer = CHAIN_SPACE_PTR(chain); in evbuffer_pullup()
1390 tmp = chain; in evbuffer_pullup()
1393 chain = chain->next; in evbuffer_pullup()
1394 } else if (chain->buffer_len - chain->misalign >= (size_t)size) { in evbuffer_pullup()
1396 size_t old_off = chain->off; in evbuffer_pullup()
1397 buffer = chain->buffer + chain->misalign + chain->off; in evbuffer_pullup()
1398 tmp = chain; in evbuffer_pullup()
1401 chain = chain->next; in evbuffer_pullup()
1416 for (; chain != NULL && (size_t)size >= chain->off; chain = next) { in evbuffer_pullup()
1417 next = chain->next; in evbuffer_pullup()
1419 memcpy(buffer, chain->buffer + chain->misalign, chain->off); in evbuffer_pullup()
1420 size -= chain->off; in evbuffer_pullup()
1421 buffer += chain->off; in evbuffer_pullup()
1422 if (chain == last_with_data) in evbuffer_pullup()
1424 if (&chain->next == buf->last_with_datap) in evbuffer_pullup()
1427 evbuffer_chain_free(chain); in evbuffer_pullup()
1430 if (chain != NULL) { in evbuffer_pullup()
1431 memcpy(buffer, chain->buffer + chain->misalign, size); in evbuffer_pullup()
1432 chain->misalign += size; in evbuffer_pullup()
1433 chain->off -= size; in evbuffer_pullup()
1438 tmp->next = chain; in evbuffer_pullup()
1469 struct evbuffer_chain *chain = it->internal_.chain; in evbuffer_strchr() local
1471 while (chain != NULL) { in evbuffer_strchr()
1472 char *buffer = (char *)chain->buffer + chain->misalign; in evbuffer_strchr()
1473 char *cp = memchr(buffer+i, chr, chain->off-i); in evbuffer_strchr()
1475 it->internal_.chain = chain; in evbuffer_strchr()
1480 it->pos += chain->off - i; in evbuffer_strchr()
1482 chain = chain->next; in evbuffer_strchr()
1518 struct evbuffer_chain *chain = it->internal_.chain; in evbuffer_find_eol_char() local
1520 while (chain != NULL) { in evbuffer_find_eol_char()
1521 char *buffer = (char *)chain->buffer + chain->misalign; in evbuffer_find_eol_char()
1522 char *cp = find_eol_char(buffer+i, chain->off-i); in evbuffer_find_eol_char()
1524 it->internal_.chain = chain; in evbuffer_find_eol_char()
1529 it->pos += chain->off - i; in evbuffer_find_eol_char()
1531 chain = chain->next; in evbuffer_find_eol_char()
1542 struct evbuffer_chain *chain = ptr->internal_.chain; in evbuffer_strspn() local
1545 if (!chain) in evbuffer_strspn()
1549 char *buffer = (char *)chain->buffer + chain->misalign; in evbuffer_strspn()
1550 for (; i < chain->off; ++i) { in evbuffer_strspn()
1556 ptr->internal_.chain = chain; in evbuffer_strspn()
1565 if (! chain->next) { in evbuffer_strspn()
1566 ptr->internal_.chain = chain; in evbuffer_strspn()
1572 chain = chain->next; in evbuffer_strspn()
1580 struct evbuffer_chain *chain = it->internal_.chain; in evbuffer_getchr() local
1583 if (chain == NULL) in evbuffer_getchr()
1586 return (unsigned char)chain->buffer[chain->misalign + off]; in evbuffer_getchr()
1599 if (start && start->internal_.chain == NULL) { in evbuffer_search_eol()
1612 it.internal_.chain = buffer->first; in evbuffer_search_eol()
1725 struct evbuffer_chain *chain, *tmp; in evbuffer_add() local
1741 chain = buf->last; in evbuffer_add()
1743 chain = *buf->last_with_datap; in evbuffer_add()
1748 if (chain == NULL) { in evbuffer_add()
1749 chain = evbuffer_chain_new(datlen); in evbuffer_add()
1750 if (!chain) in evbuffer_add()
1752 evbuffer_chain_insert(buf, chain); in evbuffer_add()
1755 if ((chain->flags & EVBUFFER_IMMUTABLE) == 0) { in evbuffer_add()
1757 EVUTIL_ASSERT(chain->misalign >= 0 && in evbuffer_add()
1758 (ev_uint64_t)chain->misalign <= EVBUFFER_CHAIN_MAX); in evbuffer_add()
1759 remain = chain->buffer_len - (size_t)chain->misalign - chain->off; in evbuffer_add()
1763 memcpy(chain->buffer + chain->misalign + chain->off, in evbuffer_add()
1765 chain->off += datlen; in evbuffer_add()
1769 } else if (!CHAIN_PINNED(chain) && in evbuffer_add()
1770 evbuffer_chain_should_realign(chain, datlen)) { in evbuffer_add()
1772 evbuffer_chain_align(chain); in evbuffer_add()
1774 memcpy(chain->buffer + chain->off, data, datlen); in evbuffer_add()
1775 chain->off += datlen; in evbuffer_add()
1786 to_alloc = chain->buffer_len; in evbuffer_add()
1796 memcpy(chain->buffer + chain->misalign + chain->off, in evbuffer_add()
1798 chain->off += remain; in evbuffer_add()
1822 struct evbuffer_chain *chain, *tmp; in evbuffer_prepend() local
1834 chain = buf->first; in evbuffer_prepend()
1836 if (chain == NULL) { in evbuffer_prepend()
1837 chain = evbuffer_chain_new(datlen); in evbuffer_prepend()
1838 if (!chain) in evbuffer_prepend()
1840 evbuffer_chain_insert(buf, chain); in evbuffer_prepend()
1844 if ((chain->flags & EVBUFFER_IMMUTABLE) == 0) { in evbuffer_prepend()
1846 EVUTIL_ASSERT(chain->misalign >= 0 && in evbuffer_prepend()
1847 (ev_uint64_t)chain->misalign <= EVBUFFER_CHAIN_MAX); in evbuffer_prepend()
1851 if (chain->off == 0) in evbuffer_prepend()
1852 chain->misalign = chain->buffer_len; in evbuffer_prepend()
1854 if ((size_t)chain->misalign >= datlen) { in evbuffer_prepend()
1856 memcpy(chain->buffer + chain->misalign - datlen, in evbuffer_prepend()
1858 chain->off += datlen; in evbuffer_prepend()
1859 chain->misalign -= datlen; in evbuffer_prepend()
1863 } else if (chain->misalign) { in evbuffer_prepend()
1865 memcpy(chain->buffer, in evbuffer_prepend()
1866 (char*)data + datlen - chain->misalign, in evbuffer_prepend()
1867 (size_t)chain->misalign); in evbuffer_prepend()
1868 chain->off += (size_t)chain->misalign; in evbuffer_prepend()
1869 buf->total_len += (size_t)chain->misalign; in evbuffer_prepend()
1870 buf->n_add_for_cb += (size_t)chain->misalign; in evbuffer_prepend()
1871 datlen -= (size_t)chain->misalign; in evbuffer_prepend()
1872 chain->misalign = 0; in evbuffer_prepend()
1883 tmp->next = chain; in evbuffer_prepend()
1903 evbuffer_chain_align(struct evbuffer_chain *chain) in evbuffer_chain_align() argument
1905 EVUTIL_ASSERT(!(chain->flags & EVBUFFER_IMMUTABLE)); in evbuffer_chain_align()
1906 EVUTIL_ASSERT(!(chain->flags & EVBUFFER_MEM_PINNED_ANY)); in evbuffer_chain_align()
1907 memmove(chain->buffer, chain->buffer + chain->misalign, chain->off); in evbuffer_chain_align()
1908 chain->misalign = 0; in evbuffer_chain_align()
1917 evbuffer_chain_should_realign(struct evbuffer_chain *chain, in evbuffer_chain_should_realign() argument
1920 return chain->buffer_len - chain->off >= datlen && in evbuffer_chain_should_realign()
1921 (chain->off < chain->buffer_len / 2) && in evbuffer_chain_should_realign()
1922 (chain->off <= MAX_TO_REALIGN_IN_EXPAND); in evbuffer_chain_should_realign()
1930 struct evbuffer_chain *chain, **chainp; in evbuffer_expand_singlechain() local
1944 chain = *chainp; in evbuffer_expand_singlechain()
1946 if (chain == NULL || in evbuffer_expand_singlechain()
1947 (chain->flags & (EVBUFFER_IMMUTABLE|EVBUFFER_MEM_PINNED_ANY))) { in evbuffer_expand_singlechain()
1954 if (CHAIN_SPACE_LEN(chain) >= datlen) { in evbuffer_expand_singlechain()
1955 result = chain; in evbuffer_expand_singlechain()
1961 if (chain->off == 0) { in evbuffer_expand_singlechain()
1971 if (evbuffer_chain_should_realign(chain, datlen)) { in evbuffer_expand_singlechain()
1972 evbuffer_chain_align(chain); in evbuffer_expand_singlechain()
1973 result = chain; in evbuffer_expand_singlechain()
1984 if (CHAIN_SPACE_LEN(chain) < chain->buffer_len / 8 || in evbuffer_expand_singlechain()
1985 chain->off > MAX_TO_COPY_IN_EXPAND || in evbuffer_expand_singlechain()
1986 datlen >= (EVBUFFER_CHAIN_MAX - chain->off)) { in evbuffer_expand_singlechain()
1989 if (chain->next && CHAIN_SPACE_LEN(chain->next) >= datlen) { in evbuffer_expand_singlechain()
1992 result = chain->next; in evbuffer_expand_singlechain()
2005 size_t length = chain->off + datlen; in evbuffer_expand_singlechain()
2011 tmp->off = chain->off; in evbuffer_expand_singlechain()
2012 memcpy(tmp->buffer, chain->buffer + chain->misalign, in evbuffer_expand_singlechain()
2013 chain->off); in evbuffer_expand_singlechain()
2015 EVUTIL_ASSERT(*chainp == chain); in evbuffer_expand_singlechain()
2018 if (buf->last == chain) in evbuffer_expand_singlechain()
2021 tmp->next = chain->next; in evbuffer_expand_singlechain()
2022 evbuffer_chain_free(chain); in evbuffer_expand_singlechain()
2042 struct evbuffer_chain *chain = buf->last, *tmp, *next; in evbuffer_expand_fast_() local
2049 if (chain == NULL || (chain->flags & EVBUFFER_IMMUTABLE)) { in evbuffer_expand_fast_()
2052 chain = evbuffer_chain_new(datlen); in evbuffer_expand_fast_()
2053 if (chain == NULL) in evbuffer_expand_fast_()
2056 evbuffer_chain_insert(buf, chain); in evbuffer_expand_fast_()
2065 for (chain = *buf->last_with_datap; chain; chain = chain->next) { in evbuffer_expand_fast_()
2066 if (chain->off) { in evbuffer_expand_fast_()
2067 size_t space = (size_t) CHAIN_SPACE_LEN(chain); in evbuffer_expand_fast_()
2068 EVUTIL_ASSERT(chain == *buf->last_with_datap); in evbuffer_expand_fast_()
2075 chain->misalign = 0; in evbuffer_expand_fast_()
2076 avail += chain->buffer_len; in evbuffer_expand_fast_()
2093 EVUTIL_ASSERT(chain == NULL); in evbuffer_expand_fast_()
2108 chain = *buf->last_with_datap; in evbuffer_expand_fast_()
2109 if (!chain->off) { in evbuffer_expand_fast_()
2110 EVUTIL_ASSERT(chain == buf->first); in evbuffer_expand_fast_()
2116 avail = (size_t) CHAIN_SPACE_LEN(chain); in evbuffer_expand_fast_()
2117 chain = chain->next; in evbuffer_expand_fast_()
2121 for (; chain; chain = next) { in evbuffer_expand_fast_()
2122 next = chain->next; in evbuffer_expand_fast_()
2123 EVUTIL_ASSERT(chain->off == 0); in evbuffer_expand_fast_()
2124 evbuffer_chain_free(chain); in evbuffer_expand_fast_()
2152 struct evbuffer_chain *chain; in evbuffer_expand() local
2155 chain = evbuffer_expand_singlechain(buf, datlen); in evbuffer_expand()
2157 return chain ? 0 : -1; in evbuffer_expand()
2218 struct evbuffer_chain *chain; in evbuffer_read_setup_vecs_() local
2234 chain = *firstchainp; in evbuffer_read_setup_vecs_()
2236 size_t avail = (size_t) CHAIN_SPACE_LEN(chain); in evbuffer_read_setup_vecs_()
2239 vecs[i].iov_base = (void *)CHAIN_SPACE_PTR(chain); in evbuffer_read_setup_vecs_()
2242 chain = chain->next; in evbuffer_read_setup_vecs_()
2280 struct evbuffer_chain *chain; in evbuffer_read() local
2342 if ((chain = evbuffer_expand_singlechain(buf, howmuch)) == NULL) { in evbuffer_read()
2348 p = chain->buffer + chain->misalign + chain->off; in evbuffer_read()
2387 chain->off += n; in evbuffer_read()
2407 struct evbuffer_chain *chain = buffer->first; in evbuffer_write_iovec() local
2417 while (chain != NULL && i < NUM_WRITE_IOVEC && howmuch) { in evbuffer_write_iovec()
2420 if (chain->flags & EVBUFFER_SENDFILE) in evbuffer_write_iovec()
2423 iov[i].IOV_PTR_FIELD = (void *) (chain->buffer + chain->misalign); in evbuffer_write_iovec()
2424 if ((size_t)howmuch >= chain->off) { in evbuffer_write_iovec()
2426 iov[i++].IOV_LEN_FIELD = (IOV_LEN_TYPE)chain->off; in evbuffer_write_iovec()
2427 howmuch -= chain->off; in evbuffer_write_iovec()
2433 chain = chain->next; in evbuffer_write_iovec()
2458 struct evbuffer_chain *chain = buffer->first; in evbuffer_write_sendfile() local
2461 chain); in evbuffer_write_sendfile()
2465 ev_off_t len = chain->off; in evbuffer_write_sendfile()
2468 ev_off_t offset = chain->misalign; in evbuffer_write_sendfile()
2474 res = sendfile(source_fd, dest_fd, chain->misalign, &len, NULL, 0); in evbuffer_write_sendfile()
2480 res = sendfile(source_fd, dest_fd, chain->misalign, chain->off, NULL, &len, 0); in evbuffer_write_sendfile()
2487 res = sendfile(dest_fd, source_fd, &offset, chain->off); in evbuffer_write_sendfile()
2496 res = sendfile(dest_fd, source_fd, &offset, chain->off); in evbuffer_write_sendfile()
2527 struct evbuffer_chain *chain = buffer->first; in evbuffer_write_atmost() local
2528 if (chain != NULL && (chain->flags & EVBUFFER_SENDFILE)) in evbuffer_write_atmost()
2597 if (pos->internal_.chain && howfar <= pos->internal_.pos_in_chain) { in evbuffer_ptr_subtract()
2614 struct evbuffer_chain *chain = NULL; in evbuffer_ptr_set() local
2621 chain = buf->first; in evbuffer_ptr_set()
2632 chain = pos->internal_.chain; in evbuffer_ptr_set()
2639 while (chain && position + left >= chain->off) { in evbuffer_ptr_set()
2640 left -= chain->off - position; in evbuffer_ptr_set()
2641 chain = chain->next; in evbuffer_ptr_set()
2644 if (chain) { in evbuffer_ptr_set()
2645 pos->internal_.chain = chain; in evbuffer_ptr_set()
2649 pos->internal_.chain = NULL; in evbuffer_ptr_set()
2669 struct evbuffer_chain *chain; in evbuffer_ptr_memcmp() local
2680 chain = pos->internal_.chain; in evbuffer_ptr_memcmp()
2682 while (len && chain) { in evbuffer_ptr_memcmp()
2684 if (len + position > chain->off) in evbuffer_ptr_memcmp()
2685 n_comparable = chain->off - position; in evbuffer_ptr_memcmp()
2688 r = memcmp(chain->buffer + chain->misalign + position, mem, in evbuffer_ptr_memcmp()
2695 chain = chain->next; in evbuffer_ptr_memcmp()
2711 struct evbuffer_chain *chain, *last_chain = NULL; in evbuffer_search_range() local
2719 chain = pos.internal_.chain; in evbuffer_search_range()
2722 chain = pos.internal_.chain = buffer->first; in evbuffer_search_range()
2727 last_chain = end->internal_.chain; in evbuffer_search_range()
2734 while (chain) { in evbuffer_search_range()
2736 chain->buffer + chain->misalign + in evbuffer_search_range()
2739 chain->off - pos.internal_.pos_in_chain); in evbuffer_search_range()
2751 if (pos.internal_.pos_in_chain == chain->off) { in evbuffer_search_range()
2752 chain = pos.internal_.chain = chain->next; in evbuffer_search_range()
2756 if (chain == last_chain) in evbuffer_search_range()
2758 pos.pos += chain->off - pos.internal_.pos_in_chain; in evbuffer_search_range()
2759 chain = pos.internal_.chain = chain->next; in evbuffer_search_range()
2776 struct evbuffer_chain *chain; in evbuffer_peek() local
2781 if (start_at && start_at->internal_.chain == NULL) in evbuffer_peek()
2787 chain = start_at->internal_.chain; in evbuffer_peek()
2788 len_so_far = chain->off in evbuffer_peek()
2792 vec[0].iov_base = (void *)(chain->buffer + chain->misalign in evbuffer_peek()
2796 chain = chain->next; in evbuffer_peek()
2798 chain = buffer->first; in evbuffer_peek()
2810 while (chain) { in evbuffer_peek()
2814 vec[idx].iov_base = (void *)(chain->buffer + chain->misalign); in evbuffer_peek()
2815 vec[idx].iov_len = chain->off; in evbuffer_peek()
2820 len_so_far += chain->off; in evbuffer_peek()
2821 chain = chain->next; in evbuffer_peek()
2837 struct evbuffer_chain *chain; in evbuffer_add_vprintf() local
2847 if ((chain = evbuffer_expand_singlechain(buf, 64)) == NULL) in evbuffer_add_vprintf()
2852 size_t used = chain->misalign + chain->off; in evbuffer_add_vprintf()
2853 buffer = (char *)chain->buffer + chain->misalign + chain->off; in evbuffer_add_vprintf()
2854 EVUTIL_ASSERT(chain->buffer_len >= used); in evbuffer_add_vprintf()
2855 space = chain->buffer_len - used; in evbuffer_add_vprintf()
2857 buffer = (char*) CHAIN_SPACE_PTR(chain); in evbuffer_add_vprintf()
2858 space = (size_t) CHAIN_SPACE_LEN(chain); in evbuffer_add_vprintf()
2875 chain->off += sz; in evbuffer_add_vprintf()
2884 if ((chain = evbuffer_expand_singlechain(buf, sz + 1)) == NULL) in evbuffer_add_vprintf()
2912 struct evbuffer_chain *chain; in evbuffer_add_reference() local
2916 chain = evbuffer_chain_new(sizeof(struct evbuffer_chain_reference)); in evbuffer_add_reference()
2917 if (!chain) in evbuffer_add_reference()
2919 chain->flags |= EVBUFFER_REFERENCE | EVBUFFER_IMMUTABLE; in evbuffer_add_reference()
2920 chain->buffer = (unsigned char *)data; in evbuffer_add_reference()
2921 chain->buffer_len = datlen; in evbuffer_add_reference()
2922 chain->off = datlen; in evbuffer_add_reference()
2924 info = EVBUFFER_CHAIN_EXTRA(struct evbuffer_chain_reference, chain); in evbuffer_add_reference()
2932 mm_free(chain); in evbuffer_add_reference()
2935 evbuffer_chain_insert(outbuf, chain); in evbuffer_add_reference()
3184 struct evbuffer_chain *chain; in evbuffer_add_file_segment() local
3217 chain = evbuffer_chain_new(sizeof(struct evbuffer_chain_file_segment)); in evbuffer_add_file_segment()
3218 if (!chain) in evbuffer_add_file_segment()
3220 extra = EVBUFFER_CHAIN_EXTRA(struct evbuffer_chain_file_segment, chain); in evbuffer_add_file_segment()
3222 chain->flags |= EVBUFFER_IMMUTABLE|EVBUFFER_FILESEGMENT; in evbuffer_add_file_segment()
3224 chain->flags |= EVBUFFER_SENDFILE; in evbuffer_add_file_segment()
3225 chain->misalign = seg->file_offset + offset; in evbuffer_add_file_segment()
3226 chain->off = length; in evbuffer_add_file_segment()
3227 chain->buffer_len = chain->misalign + length; in evbuffer_add_file_segment()
3247 mm_free(chain); in evbuffer_add_file_segment()
3250 chain->buffer = (unsigned char*) data; in evbuffer_add_file_segment()
3251 chain->buffer_len = length+offset_remaining; in evbuffer_add_file_segment()
3252 chain->misalign = offset_remaining; in evbuffer_add_file_segment()
3253 chain->off = length; in evbuffer_add_file_segment()
3255 chain->buffer = (unsigned char*)(seg->contents + offset); in evbuffer_add_file_segment()
3256 chain->buffer_len = length; in evbuffer_add_file_segment()
3257 chain->off = length; in evbuffer_add_file_segment()
3260 chain->buffer = (unsigned char*)(seg->contents + offset); in evbuffer_add_file_segment()
3261 chain->buffer_len = length; in evbuffer_add_file_segment()
3262 chain->off = length; in evbuffer_add_file_segment()
3267 evbuffer_chain_insert(buf, chain); in evbuffer_add_file_segment()