扩展evbuffer的可用空间,该函数会改变buffer中的最后一个内存块,或者添加一个新的内存块,将buffer的可用空间扩展到至少datlen个字节。扩展buffer到足够大,从而在不需要进行更多的分配情况下就能容纳datlen个字节。 /* Here are two ways to add"Hello world 2.0.1" to a buffer. */ /* Directly: */ evbuffer...
intevbuffer_defer_callbacks(structevbuffer *buffer,structevent_base *base); //避免数据拷贝的 基本的ebuffer-IO typedefvoid(*evbuffer_ref_cleanup_cb)(constvoid*data, size_t datalen,void*extra); intevbuffer_add_reference(structevbuffer *outbuf, constvoid*data, size_t datlen, evbuffer_ref_cleanup...
int evbuffer_add_vprintf(struct evbuffer *buf, const char *fmt, va_list ap); 直接往evbuffer的末尾添加数据 int evbuffer_expand (struct evbuffer *buf, size_t data_len); 扩展ev_buffer的预申请内存 int evbuffer_add_buffer (struct evbuffer *dst, struct evbuffer *src); int evbuffer_rename_buffer...
/* Suppose we want to fill a buffer with 2048 bytes of output from agenerate_data() function, without copying. */structevbuffer_iovec v[2];intn, i;size_t n_to_add = 2048;/* Reserve 2048 bytes.*/n = evbuffer_reserve_space(buf, n_to_add, v, 2);if(n<=0)return; /* Unable ...
Sometimes, though, you may have data with special constraints: it may be read-only, or it may be memory-managed by someone else and bfy shouldn't free it, or you may want to transfer it from a different buffer. You can add these with the functionsbfy_buffer_add_reference(),bfy_buffer...
* For mmap, this can be a read-only buffer and * EVBUFFER_IMMUTABLE will be set in flags. For sendfile, it * may point to NULL. */ unsignedchar*buffer; }; /** callback for a reference chain; lets us know what to do with it when ...
intevbuffer_add_buffer(structevbuffer*dst,structevbuffer*src);intevbuffer_remove_buffer(structevbuffer*src,structevbuffer*dst,size_t datlen); 移动data到另一个evbuffer的首部 intevbuffer_prepend(structevbuffer*buf,constvoid*data,size_t size);intevbuffer_prepend_buffer(structevbuffer*dst,structevbuffer*src...
The evbuffer_add_buffer() function moves all data fromsrcto the end ofdst. It returns 0 on success, -1 on failure. The evbuffer_remove_buffer() function moves exactlydatlenbytes fromsrcto the end ofdst, copying as little as possible. If there are fewer thandatlenbytes to move, it mov...
evbuffer_add_buffer()将src中的所有数据移动到dst末尾,成功时返回0,失败时返回-1。 evbuffer_remove_buffer()函数从src中移动datlen字节到dst末尾,尽量少进行复制。如果字节数小于datlen,所有字节被移动。函数返回移动的字节数。 evbuffer_add_buffer()在0.8版本引入;evbuffer_remove_buffer()是2.0.1-alpha版本新增...
int evbuffer_add_reference(struct evbuffer *outbuf, const void *data, size_t datlen, evbuffer_ref_cleanup_cb cleanupfn, void *extra); 这个接口是官方文档推荐在避免内存拷贝时使用的接口,在evbuffer中直接挂接用户提供的buffer,该buffer由用户分配,当然也该由用户释放,evbuffer_ref_cleanup_cb,在evbuffer_...