summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7e76aba)
raw | patch | inline | side by side (parent: 7e76aba)
author | YONETANI Tomokazu <qhwt+git@les.ath.cx> | |
Sun, 14 Dec 2008 02:08:22 +0000 (11:08 +0900) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 15 Dec 2008 00:41:32 +0000 (16:41 -0800) |
Internal "allocate in bulk, we will never free this memory anyway"
allocator used in fast-import had a logic to round up the size of the
requested memory block in a wrong place (it computed if the available
space is enough to fit the request first, and then carved a chunk of
memory by size rounded up to the alignment, which could go beyond the
actually available space).
Signed-off-by: Junio C Hamano <gitster@pobox.com>
allocator used in fast-import had a logic to round up the size of the
requested memory block in a wrong place (it computed if the available
space is enough to fit the request first, and then carved a chunk of
memory by size rounded up to the alignment, which could go beyond the
actually available space).
Signed-off-by: Junio C Hamano <gitster@pobox.com>
fast-import.c | patch | blob | history |
diff --git a/fast-import.c b/fast-import.c
index 3c035a57886329acf4d53a600af0a82ee55d514b..3276d5d7aa49aaf41cf9f9e3562a5bbd14b63c18 100644 (file)
--- a/fast-import.c
+++ b/fast-import.c
struct mem_pool *p;
void *r;
+ /* round up to a 'uintmax_t' alignment */
+ if (len & (sizeof(uintmax_t) - 1))
+ len += sizeof(uintmax_t) - (len & (sizeof(uintmax_t) - 1));
+
for (p = mem_pool; p; p = p->next_pool)
if ((p->end - p->next_free >= len))
break;
}
r = p->next_free;
- /* 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;
}