Hi,
> bufferevent_read_pressure_cb() may not use the second argument, but
> other users of the evbuffer API can and likely do. (The evbuffer API
> is, after all, exported in event.h.)
>
> I don't want to break existing code if I can help it.
I understand that breaking existing API is not a good solution.
However, we can still avoid passing unneeded arguments to
bufferevent_read_pressure_cb.
Here's an updated patch which removes unneeded arguments without
breaking the evbuffer API.
Regards,
Charles Longeau
Index: buffer.c
===================================================================
--- buffer.c (revision 504)
+++ buffer.c (working copy)
@@ -116,7 +116,7 @@
* of data that we transfered from inbuf to outbuf
*/
if (inbuf->off != oldoff && inbuf->cb != NULL)
- (*inbuf->cb)(inbuf, oldoff, inbuf->off, inbuf->cbarg);
+ (*inbuf->cb)(inbuf, 0, inbuf->off, inbuf->cbarg);
if (oldoff && outbuf->cb != NULL)
(*outbuf->cb)(outbuf, 0, oldoff, outbuf->cbarg);
@@ -137,7 +137,6 @@
{
char *buffer;
size_t space;
- size_t oldoff = buf->off;
int sz;
va_list aq;
@@ -168,7 +167,7 @@
if (sz < space) {
buf->off += sz;
if (buf->cb != NULL)
- (*buf->cb)(buf, oldoff, buf->off, buf->cbarg);
+ (*buf->cb)(buf, 0, buf->off, buf->cbarg);
return (sz);
}
if (evbuffer_expand(buf, sz + 1) == -1)
@@ -305,7 +304,6 @@
evbuffer_add(struct evbuffer *buf, const void *data, size_t datlen)
{
size_t need = buf->misalign + buf->off + datlen;
- size_t oldoff = buf->off;
if (buf->totallen < need) {
if (evbuffer_expand(buf, datlen) == -1)
@@ -316,7 +314,7 @@
buf->off += datlen;
if (datlen && buf->cb != NULL)
- (*buf->cb)(buf, oldoff, buf->off, buf->cbarg);
+ (*buf->cb)(buf, 0, buf->off, buf->cbarg);
return (0);
}
@@ -341,7 +339,7 @@
done:
/* Tell someone about changes in this buffer */
if (buf->off != oldoff && buf->cb != NULL)
- (*buf->cb)(buf, oldoff, buf->off, buf->cbarg);
+ (*buf->cb)(buf, 0, buf->off, buf->cbarg);
}
@@ -404,7 +402,7 @@
/* Tell someone about changes in this buffer */
if (buf->off != oldoff && buf->cb != NULL)
- (*buf->cb)(buf, oldoff, buf->off, buf->cbarg);
+ (*buf->cb)(buf, 0, buf->off, buf->cbarg);
return (n);
}
_______________________________________________
Libevent-users mailing list
[email protected]
http://monkeymail.org/mailman/listinfo/libevent-users