diff options
author | David S. Miller <davem@davemloft.net> | 2007-12-14 20:39:16 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2007-12-14 20:39:16 -0800 |
commit | 69ae517541ed5ab7d4fdcd8f82a9b8bd949df347 (patch) | |
tree | 0285db08bcf3f2b9f1f719a63b22691a4de4b3f4 /fast-import.c | |
parent | 896c0535afe2f00683f7d4e8171fad7ec156f16f (diff) | |
download | git-69ae517541ed5ab7d4fdcd8f82a9b8bd949df347.tar.gz git-69ae517541ed5ab7d4fdcd8f82a9b8bd949df347.tar.xz |
fast-import: fix unalinged allocation and access
The specialized pool allocator fast-import uses aligned objects on the
size of a pointer, which was not sufficient at least on Sparc. Instead,
make the alignment for objects of type unitmax_t.
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'fast-import.c')
-rw-r--r-- | fast-import.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/fast-import.c b/fast-import.c index 98c2bd535..4646c056f 100644 --- a/fast-import.c +++ b/fast-import.c @@ -196,7 +196,7 @@ struct mem_pool struct mem_pool *next_pool; char *next_free; char *end; - char space[FLEX_ARRAY]; /* more */ + uintmax_t space[FLEX_ARRAY]; /* more */ }; struct atom_str @@ -534,15 +534,15 @@ static void *pool_alloc(size_t len) total_allocd += sizeof(struct mem_pool) + mem_pool_alloc; p = xmalloc(sizeof(struct mem_pool) + mem_pool_alloc); p->next_pool = mem_pool; - p->next_free = p->space; + p->next_free = (char *) p->space; p->end = p->next_free + mem_pool_alloc; mem_pool = p; } r = p->next_free; - /* round out to a pointer alignment */ - if (len & (sizeof(void*) - 1)) - len += sizeof(void*) - (len & (sizeof(void*) - 1)); + /* round out to a 'uintmax_t' alignment */ + if (len & (sizeof(uintmax_t) - 1)) + len += sizeof(uintmax_t) - (len & (sizeof(uintmax_t) - 1)); p->next_free += len; return r; } |