Re: [PATCH 3/4] unpack-trees: trivial cleanup
On Mon, Jun 3, 2013 at 12:13 PM, Junio C Hamano wrote: > Felipe Contreras writes: > >> dfc has not been initialized at this point. >> >> Signed-off-by: Felipe Contreras >> --- > > Upon the first entry to this function, because dfc is > > static struct cache_entry *dfc; Ah, I didn't notice it's static. Smells error-prone, but I guess it's OK for now. -- Felipe Contreras -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/4] unpack-trees: trivial cleanup
Felipe Contreras writes: > dfc has not been initialized at this point. > > Signed-off-by: Felipe Contreras > --- Upon the first entry to this function, because dfc is static struct cache_entry *dfc; it is NULL. In that case, we allocate one instance. When the function is called again, we can reuse the entry, because it merely acts as a unique sentinel value. And we do not free() it. > unpack-trees.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/unpack-trees.c b/unpack-trees.c > index ede4299..36f4ff7 100644 > --- a/unpack-trees.c > +++ b/unpack-trees.c > @@ -1040,8 +1040,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, > struct unpack_trees_options > if (!o->skip_sparse_checkout) > mark_new_skip_worktree(o->el, o->src_index, 0, > CE_NEW_SKIP_WORKTREE); > > - if (!dfc) > - dfc = xcalloc(1, cache_entry_size(0)); > + dfc = xcalloc(1, cache_entry_size(0)); > o->df_conflict_entry = dfc; > > if (len) { -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/4] unpack-trees: trivial cleanup
dfc has not been initialized at this point. Signed-off-by: Felipe Contreras --- unpack-trees.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/unpack-trees.c b/unpack-trees.c index ede4299..36f4ff7 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -1040,8 +1040,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options if (!o->skip_sparse_checkout) mark_new_skip_worktree(o->el, o->src_index, 0, CE_NEW_SKIP_WORKTREE); - if (!dfc) - dfc = xcalloc(1, cache_entry_size(0)); + dfc = xcalloc(1, cache_entry_size(0)); o->df_conflict_entry = dfc; if (len) { -- 1.8.3.rc3.312.g47657de -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html