summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2003-10-19 01:10:38 +0000
committerRoger Dingledine <arma@torproject.org>2003-10-19 01:10:38 +0000
commitefce1b8b3e9654fd83f8c43614f42c96552f2408 (patch)
tree6a3afacbfbb2a8ede6e17688b89511cbb48ada97
parent0142a568d30034088cabb67849e9c8828fb18318 (diff)
downloadtor-efce1b8b3e9654fd83f8c43614f42c96552f2408.tar.gz
tor-efce1b8b3e9654fd83f8c43614f42c96552f2408.zip
put small buffers back in place
svn:r629
-rw-r--r--src/or/buffers.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/or/buffers.c b/src/or/buffers.c
index 1a3c9e6d4b..9a8e64ccaf 100644
--- a/src/or/buffers.c
+++ b/src/or/buffers.c
@@ -6,27 +6,27 @@
#include "or.h"
-extern or_options_t options; /* command-line and config-file options */
-
struct buf_t {
char *mem;
size_t len;
size_t datalen;
};
+
/* Size, in bytes, for newly allocated buffers. Should be a power of 2. */
-#define INITIAL_BUF_SIZE (512*1024) /* used to be 4*1024 */
+#define INITIAL_BUF_SIZE (4*1024)
/* Maximum size, in bytes, for resized buffers. */
#define MAX_BUF_SIZE (1024*1024)
/* Size, in bytes, for minimum 'shrink' size for buffers. Buffers may start
* out smaller than this, but they will never autoshrink to less
* than this size. */
-#define MIN_BUF_SHRINK_SIZE (512*1024) /* used to be 16*1024 */
+#define MIN_BUF_SHRINK_SIZE (16*1024)
#define BUF_OK(b) ((b) && (b)->mem && (b)->datalen <= (b)->len)
/* Change a buffer's capacity. Must only be called when */
static INLINE void buf_resize(buf_t *buf, size_t new_capacity)
{
assert(buf->datalen <= new_capacity);
+ assert(new_capacity);
buf->mem = tor_realloc(buf->mem, new_capacity);
buf->len = new_capacity;
}
@@ -154,8 +154,6 @@ void buf_free(buf_t *buf) {
free(buf);
}
-
-
/* read from socket s, writing onto end of buf.
* read at most 'at_most' bytes, and in any case don't read more than will fit based on buflen.
* If read() returns 0, set *reached_eof to 1 and return 0. If you want to tear