From 582eb8536bfc93e403b008e2d660a6f246a2ff46 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Thu, 30 May 2013 08:56:18 -0500 Subject: [PATCH 1/2] read-cache: fix wrong 'the_index' usage We are dealing with the 'istate' index, not 'the_index'. Signed-off-by: Felipe Contreras Signed-off-by: Junio C Hamano --- read-cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/read-cache.c b/read-cache.c index fda78bc353..aeda7180ba 100644 --- a/read-cache.c +++ b/read-cache.c @@ -622,7 +622,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st, if (*ptr == '/') { struct cache_entry *foundce; ++ptr; - foundce = index_name_exists(&the_index, ce->name, ptr - ce->name, ignore_case); + foundce = index_name_exists(istate, ce->name, ptr - ce->name, ignore_case); if (foundce) { memcpy((void *)startPtr, foundce->name + (startPtr - ce->name), ptr - startPtr); startPtr = ptr; From c4aa3167fe9dd0b94594c20d8b3673929fcb217d Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Thu, 30 May 2013 08:56:19 -0500 Subject: [PATCH 2/2] read-cache: trivial style cleanups Signed-off-by: Felipe Contreras Signed-off-by: Junio C Hamano --- read-cache.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/read-cache.c b/read-cache.c index aeda7180ba..3bb5c91d06 100644 --- a/read-cache.c +++ b/read-cache.c @@ -975,7 +975,7 @@ int add_index_entry(struct index_state *istate, struct cache_entry *ce, int opti if (istate->cache_nr == istate->cache_alloc) { istate->cache_alloc = alloc_nr(istate->cache_alloc); istate->cache = xrealloc(istate->cache, - istate->cache_alloc * sizeof(struct cache_entry *)); + istate->cache_alloc * sizeof(*istate->cache)); } /* Add it in.. */ @@ -1445,7 +1445,7 @@ int read_index_from(struct index_state *istate, const char *path) istate->version = ntohl(hdr->hdr_version); istate->cache_nr = ntohl(hdr->hdr_entries); istate->cache_alloc = alloc_nr(istate->cache_nr); - istate->cache = xcalloc(istate->cache_alloc, sizeof(struct cache_entry *)); + istate->cache = xcalloc(istate->cache_alloc, sizeof(*istate->cache)); istate->initialized = 1; if (istate->version == 4)