aboutsummaryrefslogtreecommitdiff
path: root/src/or/buffers.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2007-07-17 09:26:45 +0000
committerRoger Dingledine <arma@torproject.org>2007-07-17 09:26:45 +0000
commitfcbb817db5507e85bba2d2b743dc0bd66fbf6103 (patch)
treea29c0a87c921595cadcdc111a2d89785c47bae46 /src/or/buffers.c
parentccfda2e3a32e180598d9b6c7f4fe8c3983763b64 (diff)
downloadtor-fcbb817db5507e85bba2d2b743dc0bd66fbf6103.tar.gz
tor-fcbb817db5507e85bba2d2b743dc0bd66fbf6103.zip
free another string, and the buffer freelists, on exit.
svn:r10851
Diffstat (limited to 'src/or/buffers.c')
-rw-r--r--src/or/buffers.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/or/buffers.c b/src/or/buffers.c
index 9ddd014529..cfb3613d18 100644
--- a/src/or/buffers.c
+++ b/src/or/buffers.c
@@ -254,9 +254,10 @@ buf_get_initial_mem(buf_t *buf, size_t sz)
}
/** Remove elements from the freelists that haven't been needed since the
- * last call to this function. */
+ * last call to this function. If <b>free_all</b>, we're exiting and we
+ * should clear the whole lists. */
void
-buf_shrink_freelists(void)
+buf_shrink_freelists(int free_all)
{
int j;
for (j = 0; j < 2; ++j) {
@@ -267,8 +268,10 @@ buf_shrink_freelists(void)
log_info(LD_GENERAL, "We haven't used %d/%d allocated %d-byte buffer "
"memory chunks since the last call; freeing all but %d of them",
list->lowwater, list->len, (int)list->chunksize, list->slack);
- /* Skip over the slack and non-lowwater entries */
- n_to_free = list->lowwater - list->slack;
+ if (free_all) /* Free every one of them */
+ n_to_free = list->len;
+ else /* Skip over the slack and non-lowwater entries */
+ n_to_free = list->lowwater - list->slack;
n_to_skip = list->len - n_to_free;
for (ptr = &list->list, i = 0; i < n_to_skip; ++i) {
char *mem = *ptr;