[or-cvs] When removing all bytes from a buffer, reset buf->cur=buf->...

Nick Mathewson nickm at seul.org
Mon May 2 23:32:26 UTC 2005


Update of /home/or/cvsroot/tor/src/or
In directory moria.mit.edu:/tmp/cvs-serv26148/src/or

Modified Files:
	buffers.c or.h 
Log Message:
When removing all bytes from a buffer, reset buf->cur=buf->mem

Index: buffers.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/buffers.c,v
retrieving revision 1.146
retrieving revision 1.147
diff -u -d -r1.146 -r1.147
--- buffers.c	2 May 2005 23:17:08 -0000	1.146
+++ buffers.c	2 May 2005 23:32:23 -0000	1.147
@@ -267,7 +267,11 @@
 static INLINE void buf_remove_from_front(buf_t *buf, size_t n) {
   tor_assert(buf->datalen >= n);
   buf->datalen -= n;
-  buf->cur = _wrap_ptr(buf, buf->cur+n);
+  if (buf->datalen) {
+    buf->cur = _wrap_ptr(buf, buf->cur+n);
+  } else {
+    buf->cur = buf->mem;
+  }
   buf_shrink_if_underfull(buf);
   check();
 }

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.600
retrieving revision 1.601
diff -u -d -r1.600 -r1.601
--- or.h	2 May 2005 23:17:08 -0000	1.600
+++ or.h	2 May 2005 23:32:23 -0000	1.601
@@ -1127,7 +1127,6 @@
 
 size_t buf_datalen(const buf_t *buf);
 size_t buf_capacity(const buf_t *buf);
-unsigned int buf_n_times_resized(const buf_t *buf);
 const char *_buf_peek_raw_buffer(const buf_t *buf);
 
 int read_to_buf(int s, size_t at_most, buf_t *buf, int *reached_eof);



More information about the tor-commits mailing list