aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2006-08-24 04:46:29 -0400
committerShawn O. Pearce <spearce@spearce.org>2007-01-14 02:15:06 -0500
commit8d8928b0511313ba1740d39c3920f8f12f36a10a (patch)
tree0eda41860d16d709cbc39be59732405691190574
parent41e5257fcf4db31dfa2576aac1f50b140f2bb058 (diff)
downloadgit-8d8928b0511313ba1740d39c3920f8f12f36a10a.tar.gz
git-8d8928b0511313ba1740d39c3920f8f12f36a10a.tar.xz
Round out memory pool allocations in fast-import to pointer sizes.
Some architectures (e.g. SPARC) would require that we access pointers only on pointer-sized alignments. So ensure the pool allocator rounds out non-pointer sized allocations to the next pointer so we don't generate bad memory addresses. This could have occurred if we had previously allocated an atom whose string was not a whole multiple of the pointer size, for example. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
-rw-r--r--fast-import.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/fast-import.c b/fast-import.c
index 1c74b90c8..e42bdbd3a 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -342,6 +342,9 @@ static void* pool_alloc(size_t len)
}
r = p->next_free;
+ /* round out to a pointer alignment */
+ if (len & (sizeof(void*) - 1))
+ len += sizeof(void*) - (len & (sizeof(void*) - 1));
p->next_free += len;
return r;
}