summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-03-26 10:09:19 -0400
committerNick Mathewson <nickm@torproject.org>2016-03-26 10:09:19 -0400
commitcc90b57b045596a3ace603b23c6c932c841cb050 (patch)
treef20e5066abb2c3d0da33ce37792d34658e6b0285
parentc0568a89d93e05d98f4ef57d0b7bb659a357dbef (diff)
downloadtor-cc90b57b045596a3ace603b23c6c932c841cb050.tar.gz
tor-cc90b57b045596a3ace603b23c6c932c841cb050.zip
add a little documentation to memarea. (I have been testing a tool.)
-rw-r--r--src/common/memarea.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/common/memarea.c b/src/common/memarea.c
index 5d5dc0caf6..cfba80be93 100644
--- a/src/common/memarea.c
+++ b/src/common/memarea.c
@@ -21,6 +21,8 @@
* value. */
#define MEMAREA_ALIGN SIZEOF_VOID_P
+/** A value which, when masked out of a pointer, produces a maximally aligned
+ * pointer. */
#if MEMAREA_ALIGN == 4
#define MEMAREA_ALIGN_MASK 3lu
#elif MEMAREA_ALIGN == 8
@@ -31,6 +33,7 @@
#if defined(__GNUC__) && defined(FLEXIBLE_ARRAY_MEMBER)
#define USE_ALIGNED_ATTRIBUTE
+/** Name for the 'memory' member of a memory chunk. */
#define U_MEM mem
#else
#define U_MEM u.mem
@@ -83,12 +86,14 @@ typedef struct memarea_chunk_t {
* greater than or equal to mem+mem_size, this chunk is
* full. */
#ifdef USE_ALIGNED_ATTRIBUTE
+ /** Actual content of the memory chunk. */
char mem[FLEXIBLE_ARRAY_MEMBER] __attribute__((aligned(MEMAREA_ALIGN)));
#else
union {
char mem[1]; /**< Memory space in this chunk. */
void *void_for_alignment_; /**< Dummy; used to make sure mem is aligned. */
- } u;
+ } u; /**< Union used to enforce alignment when we don't have support for
+ * doing it right. */
#endif
} memarea_chunk_t;