mirror of
https://github.com/git/git
synced 2024-08-27 19:49:21 +00:00
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>
This commit is contained in:
parent
41e5257fcf
commit
8d8928b051
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue