summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2008-08-06 16:22:35 +0000
committerNick Mathewson <nickm@torproject.org>2008-08-06 16:22:35 +0000
commit9250b0bd62f74940eb3d16ddebd50bd94f490acb (patch)
tree4cdf1f6a64c2dbed60ed3518993464fba735d398
parentc5ef95b8028703132184eaa67b77a541971e3b8a (diff)
downloadtor-9250b0bd62f74940eb3d16ddebd50bd94f490acb.tar.gz
tor-9250b0bd62f74940eb3d16ddebd50bd94f490acb.zip
r17660@tombo: nickm | 2008-08-06 12:22:19 -0400
Backport: Fix bug 794: recover 3 bytes wasted per memory chunk. Fix from rovv. svn:r16449
-rw-r--r--ChangeLog2
-rw-r--r--src/common/mempool.c2
2 files changed, 3 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 1c12fbe97e..e8e0e37d9c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,8 @@ Changes in version 0.2.0.31 - 2008-08-??
o Minor bugfixes:
- Fix a small alignment and memory-wasting bug on buffer chunks. Spotted
by rovv.
+ - Recover 3-7 bytes that were wasted per memory chunk. Fixes bug
+ 794; bug spotted by rovv. Bugfix on 0.2.0.1-alpha.
Changes in version 0.2.0.30 - 2008-07-15
diff --git a/src/common/mempool.c b/src/common/mempool.c
index 6a41d220fe..d489cf6550 100644
--- a/src/common/mempool.c
+++ b/src/common/mempool.c
@@ -144,7 +144,7 @@ struct mp_chunk_t {
};
/** Number of extra bytes needed beyond mem_size to allocate a chunk. */
-#define CHUNK_OVERHEAD (sizeof(mp_chunk_t)-1)
+#define CHUNK_OVERHEAD STRUCT_OFFSET(mp_chunk_t, mem[0])
/** Given a pointer to a mp_allocated_t, return a pointer to the memory
* item it holds. */