[Libevent-users] [PATCH] remove useless argument in bufferevent_read_pressure_cb

2007-11-08 Thread Charles Longeau
Hello,

In bufferevent_read_pressure_cb() function, the second argument (which
is size_t old) is not used. Here's a patch which removes it.

Regards,

Charles Longeau

Index: trunk/libevent/evbuffer.c
===
--- trunk/libevent/evbuffer.c   (revision 502)
+++ trunk/libevent/evbuffer.c   (working copy)
@@ -53,7 +53,7 @@
 /* prototypes */
 
 void bufferevent_setwatermark(struct bufferevent *, short, size_t, size_t);
-void bufferevent_read_pressure_cb(struct evbuffer *, size_t, size_t, void *);
+void bufferevent_read_pressure_cb(struct evbuffer *, size_t, void *);
 
 static int
 bufferevent_add(struct event *ev, int timeout)
@@ -75,8 +75,8 @@
  */
 
 void
-bufferevent_read_pressure_cb(struct evbuffer *buf, size_t old, size_t now,
-void *arg) {
+bufferevent_read_pressure_cb(struct evbuffer *buf, size_t now, void *arg)
+{
struct bufferevent *bufev = arg;
/* 
 * If we are below the watermark then reschedule reading if it's
@@ -401,7 +401,7 @@
 
/* If the watermarks changed then see if we should call read again */
bufferevent_read_pressure_cb(bufev-input,
-   0, EVBUFFER_LENGTH(bufev-input), bufev);
+   EVBUFFER_LENGTH(bufev-input), bufev);
 }
 
 int
Index: trunk/libevent/buffer.c
===
--- trunk/libevent/buffer.c (revision 502)
+++ trunk/libevent/buffer.c (working copy)
@@ -116,9 +116,9 @@
 * 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, inbuf-off, inbuf-cbarg);
if (oldoff  outbuf-cb != NULL)
-   (*outbuf-cb)(outbuf, 0, oldoff, outbuf-cbarg);
+   (*outbuf-cb)(outbuf, oldoff, outbuf-cbarg);

return (0);
}
@@ -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, 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, 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, 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, buf-off, buf-cbarg);
 
return (n);
 }
@@ -447,7 +445,7 @@
 }
 
 void evbuffer_setcb(struct evbuffer *buffer,
-void (*cb)(struct evbuffer *, size_t, size_t, void *),
+void (*cb)(struct evbuffer *, size_t, void *),
 void *cbarg)
 {
buffer-cb = cb;
Index: trunk/libevent/event.h
===
--- trunk/libevent/event.h  (revision 502)
+++ trunk/libevent/event.h  (working copy)
@@ -660,7 +660,7 @@
size_t totallen;
size_t off;
 
-   void (*cb)(struct evbuffer *, size_t, size_t, void *);
+   void (*cb)(struct evbuffer *, size_t, void *);
void *cbarg;
 };
 
@@ -997,7 +997,7 @@
   @param cb the callback function to invoke when the evbuffer is modified
   @param cbarg an argument to be provided to the callback function
  */
-void evbuffer_setcb(struct evbuffer *, void (*)(struct evbuffer *, size_t, 
size_t, void *), void *);
+void evbuffer_setcb(struct evbuffer *, void (*)(struct evbuffer *, size_t, 
void *), void *);
 
 /*
  * Marshaling tagged data - We assume that all tags are inserted in their
___
Libevent-users mailing list
Libevent-users@monkey.org
http://monkeymail.org/mailman/listinfo/libevent-users


Re: [Libevent-users] [PATCH] remove useless argument in bufferevent_read_pressure_cb

2007-11-08 Thread Nick Mathewson
On Thu, Nov 08, 2007 at 11:05:27AM +0100, Charles Longeau wrote:
 Hello,
 
 In bufferevent_read_pressure_cb() function, the second argument (which
 is size_t old) is not used. Here's a patch which removes it.

Hi, Charles!

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.

yrs,
-- 
Nick Mathewson


pgpd6GCXYCiDt.pgp
Description: PGP signature
___
Libevent-users mailing list
Libevent-users@monkey.org
http://monkeymail.org/mailman/listinfo/libevent-users


Re: [Libevent-users] [PATCH] remove useless argument in bufferevent_read_pressure_cb

2007-11-08 Thread Nick Mathewson
On Thu, Nov 08, 2007 at 09:15:18PM +0100, Charles Longeau wrote:
 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.

I'm afraid that will still break existing code.  Any applications that
are using evbuffer will expect to get the old buffer size passed to
their callback.  For example, they may want to know how much data was
just added to the buffer.  If they get 0 instead of the original
buffer length, they will compute an incorrect answer for how much data
was just added.

yrs,
-- 
Nick Mathewson


pgpXTmdhoZ8Tt.pgp
Description: PGP signature
___
Libevent-users mailing list
Libevent-users@monkey.org
http://monkeymail.org/mailman/listinfo/libevent-users