buf->total_len += chain->off;
}
-#ifdef NOT_USED_YET
-static void
-evbuffer_chain_pin(struct evbuffer_chain *chain, unsigned flag)
+void
+_evbuffer_chain_pin(struct evbuffer_chain *chain, unsigned flag)
{
assert((chain->flags & flag) == 0);
chain->flags |= flag;
}
-static void
-evbuffer_chain_unpin(struct evbuffer_chain *chain, unsigned flag)
+void
+_evbuffer_chain_unpin(struct evbuffer_chain *chain, unsigned flag)
{
assert((chain->flags & flag) != 0);
chain->flags &= ~flag;
if (chain->flags & EVBUFFER_DANGLING)
evbuffer_chain_free(chain);
}
-#endif
struct evbuffer *
evbuffer_new(void)
EVBUFFER_LOCK(buffer, EVTHREAD_WRITE);
evbuffer_run_callbacks(buffer);
- evbuffer_free(buffer); /* release the reference */
- EVBUFFER_UNLOCK(buffer, EVTHREAD_WRITE);
+ _evbuffer_decref_and_unlock(buffer);
}
static void
}
void
-evbuffer_free(struct evbuffer *buffer)
+_evbuffer_decref_and_unlock(struct evbuffer *buffer)
{
struct evbuffer_chain *chain, *next;
+ ASSERT_EVBUFFER_LOCKED(buffer);
- EVBUFFER_LOCK(buffer, EVTHREAD_WRITE);
if (--buffer->refcnt > 0) {
EVBUFFER_UNLOCK(buffer, EVTHREAD_WRITE);
return;
mm_free(buffer);
}
+void
+evbuffer_free(struct evbuffer *buffer)
+{
+ EVBUFFER_LOCK(buffer, EVTHREAD_WRITE);
+ _evbuffer_decref_and_unlock(buffer);
+}
+
void
evbuffer_lock(struct evbuffer *buf)
{
} while(0)
void _evbuffer_incref(struct evbuffer *buf);
+void _evbuffer_chain_pin(struct evbuffer_chain *chain, unsigned flag);
+void _evbuffer_chain_unpin(struct evbuffer_chain *chain, unsigned flag);
+void _evbuffer_decref_and_unlock(struct evbuffer *buffer);
#ifdef _EVENT_HAVE_SYS_UIO_H
int _evbuffer_read_setup_vecs(struct evbuffer *buf, ssize_t howmuch,