aboutsummaryrefslogtreecommitdiff
path: root/src/common/memarea.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2009-05-17 00:05:38 -0400
committerNick Mathewson <nickm@torproject.org>2009-05-17 00:05:38 -0400
commite563874045d630c4a5bcbe7adfa6444468192039 (patch)
tree80962b61577f1ae3b6c95131d386050ea21eebbf /src/common/memarea.c
parent2619e3594258054f039617c517ad87a29358db4e (diff)
parent9f25a5529a2e7aa6226851d2b9e3ccc77abdb88a (diff)
downloadtor-e563874045d630c4a5bcbe7adfa6444468192039.tar.gz
tor-e563874045d630c4a5bcbe7adfa6444468192039.zip
Merge commit 'origin/maint-0.2.1'
Diffstat (limited to 'src/common/memarea.c')
-rw-r--r--src/common/memarea.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/common/memarea.c b/src/common/memarea.c
index 8d363fd5ac..e7f6720646 100644
--- a/src/common/memarea.c
+++ b/src/common/memarea.c
@@ -211,6 +211,8 @@ memarea_alloc(memarea_t *area, size_t sz)
char *result;
tor_assert(chunk);
CHECK_SENTINEL(chunk);
+ if (sz == 0)
+ sz = 1;
if (chunk->next_mem+sz > chunk->u.mem+chunk->mem_size) {
if (sz+CHUNK_HEADER_SIZE >= CHUNK_SIZE) {
/* This allocation is too big. Stick it in a special chunk, and put
@@ -227,10 +229,11 @@ memarea_alloc(memarea_t *area, size_t sz)
tor_assert(chunk->mem_size >= sz);
}
result = chunk->next_mem;
- chunk->next_mem = realign_pointer(chunk->next_mem + sz);
+ chunk->next_mem = chunk->next_mem + sz;
// XXXX021 remove these once bug 930 is solved.
tor_assert(chunk->next_mem >= chunk->u.mem);
tor_assert(chunk->next_mem <= chunk->u.mem+chunk->mem_size);
+ chunk->next_mem = realign_pointer(chunk->next_mem);
return result;
}
@@ -303,7 +306,8 @@ memarea_assert_ok(memarea_t *area)
for (chunk = area->first; chunk; chunk = chunk->next_chunk) {
CHECK_SENTINEL(chunk);
tor_assert(chunk->next_mem >= chunk->u.mem);
- tor_assert(chunk->next_mem <= chunk->u.mem+chunk->mem_size+MEMAREA_ALIGN);
+ tor_assert(chunk->next_mem <=
+ (char*) realign_pointer(chunk->u.mem+chunk->mem_size));
}
}