[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r16448: {tor} backport buffer chunk size fix (in tor/branches/tor-0_2_0-patches: . src/or)
Author: nickm
Date: 2008-08-06 12:22:32 -0400 (Wed, 06 Aug 2008)
New Revision: 16448
Modified:
tor/branches/tor-0_2_0-patches/
tor/branches/tor-0_2_0-patches/ChangeLog
tor/branches/tor-0_2_0-patches/src/or/buffers.c
Log:
r17505@tombo: nickm | 2008-07-31 08:24:58 -0400
backport buffer chunk size fix
Property changes on: tor/branches/tor-0_2_0-patches
___________________________________________________________________
svk:merge ticket from /tor/020 [r17505] on 49666b30-7950-49c5-bedf-9dc8f3168102
Modified: tor/branches/tor-0_2_0-patches/ChangeLog
===================================================================
--- tor/branches/tor-0_2_0-patches/ChangeLog 2008-08-06 16:22:25 UTC (rev 16447)
+++ tor/branches/tor-0_2_0-patches/ChangeLog 2008-08-06 16:22:32 UTC (rev 16448)
@@ -1,3 +1,9 @@
+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.
+
+
Changes in version 0.2.0.30 - 2008-07-15
o Minor bugfixes:
- Stop using __attribute__((nonnull)) with GCC: it can give us useful
Modified: tor/branches/tor-0_2_0-patches/src/or/buffers.c
===================================================================
--- tor/branches/tor-0_2_0-patches/src/or/buffers.c 2008-08-06 16:22:25 UTC (rev 16447)
+++ tor/branches/tor-0_2_0-patches/src/or/buffers.c 2008-08-06 16:22:32 UTC (rev 16448)
@@ -63,12 +63,14 @@
* more than one byte long. */
} chunk_t;
+#define CHUNK_HEADER_LEN STRUCT_OFFSET(chunk_t, mem[0])
+
/** Return the number of bytes needed to allocate a chunk to hold
* <b>memlen</b> bytes. */
-#define CHUNK_ALLOC_SIZE(memlen) (sizeof(chunk_t) + (memlen) - 1)
+#define CHUNK_ALLOC_SIZE(memlen) (CHUNK_HEADER_LEN + (memlen))
/** Return the number of usable bytes in a chunk allocated with
* malloc(<b>memlen</b>). */
-#define CHUNK_SIZE_WITH_ALLOC(memlen) ((memlen) - sizeof(chunk_t) + 1)
+#define CHUNK_SIZE_WITH_ALLOC(memlen) ((memlen) - CHUNK_HEADER_LEN)
/** Return the next character in <b>chunk</b> onto which data can be appended.
* If the chunk is full, this might be off the end of chunk->mem. */