put small buffers back in place

svn:r629
This commit is contained in:
Roger Dingledine 2003-10-19 01:10:38 +00:00
parent 0142a568d3
commit efce1b8b3e

View File

@ -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