{
size_t left = position;
struct evbuffer_chain *chain = NULL;
+ int result = 0;
EVBUFFER_LOCK(buf);
if (chain) {
pos->_internal.chain = chain;
pos->_internal.pos_in_chain = position + left;
+ } else if (left == 0 && buf->last) {
+ pos->_internal.chain = buf->last;
+ pos->_internal.pos_in_chain = buf->last->off;
} else {
pos->_internal.chain = NULL;
pos->pos = -1;
+ result = -1;
}
EVBUFFER_UNLOCK(buf);
- return chain != NULL ? 0 : -1;
+ return result;
}
/**
tt_assert(pos.pos == 10000);
tt_assert(evbuffer_ptr_set(buf, &pos, 1000, EVBUFFER_PTR_ADD) == 0);
tt_assert(pos.pos == 11000);
+ tt_assert(evbuffer_ptr_set(buf, &pos, 1000, EVBUFFER_PTR_ADD) == 0);
+ tt_assert(pos.pos == 12000);
tt_assert(evbuffer_ptr_set(buf, &pos, 1000, EVBUFFER_PTR_ADD) == -1);
tt_assert(pos.pos == -1);