From 9746b36cf9a86ba50a666bbc8cc97a37221cb954 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Thu, 24 Jul 2014 16:46:59 +0200 Subject: [PATCH 1/2] revwalk: remove preallocation of the uninteresting commits Preallocating two commits doesn't make much sense as leaving allocation to the first array usage will allocate a sensible size with room for growth. This preallocation has also been hiding issues with strict aliasing in the tests, as we have fairly simple histories and never trigger the growth. --- src/revwalk.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/revwalk.c b/src/revwalk.c index 530c9705e..bd07d02cb 100644 --- a/src/revwalk.c +++ b/src/revwalk.c @@ -48,9 +48,6 @@ static int mark_uninteresting(git_revwalk *walk, git_commit_list_node *commit) assert(commit); - git_array_init_to_size(pending, 2); - GITERR_CHECK_ARRAY(pending); - do { commit->uninteresting = 1; From b62a6a13b2f9a40e6ea4bf7bc2a9255429fb0bd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Fri, 25 Jul 2014 08:25:41 +0200 Subject: [PATCH 2/2] array: mark the array to grow as volatile This works around strict aliasing rules letting some versions of GCC (particularly on RHEL 6) thinking that they can skip updating the size of the array when calculating the next element's offset. --- src/array.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/array.h b/src/array.h index f8a48722a..af9eafa43 100644 --- a/src/array.h +++ b/src/array.h @@ -44,7 +44,7 @@ typedef git_array_t(char) git_array_generic_t; /* use a generic array for growth so this can return the new item */ GIT_INLINE(void *) git_array_grow(void *_a, size_t item_size) { - git_array_generic_t *a = _a; + volatile git_array_generic_t *a = _a; uint32_t new_size = (a->size < 8) ? 8 : a->asize * 3 / 2; char *new_array = git__realloc(a->ptr, new_size * item_size); if (!new_array) {