Re: [PATCH v2 3/3] unpack-trees: free created cache entries

2013-05-30 Thread René Scharfe

Am 30.05.2013 15:34, schrieb Felipe Contreras:

We created them, and nobody else is going to destroy them.

Signed-off-by: Felipe Contreras 
---
  unpack-trees.c | 12 ++--
  1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/unpack-trees.c b/unpack-trees.c
index eff2944..9f19d01 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -590,8 +590,16 @@ static int unpack_nondirectories(int n, unsigned long mask,
src[i + o->merge] = create_ce_entry(info, names + i, stage);
}

-   if (o->merge)
-   return call_unpack_fn(src, o);
+   if (o->merge) {
+   int ret = call_unpack_fn(src, o);
+   for (i = 0; i < n; i++) {
+   struct cache_entry *ce = src[i + o->merge];
+   if (!ce || ce == o->df_conflict_entry)
+   continue;
+   free(ce);
+   }
+   return ret;
+   }


Ah, now I understand what you meant in that other email.  That works as 
well, of course.  It's slightly nicer on the eye, admittedly.


René


--
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 v2 3/3] unpack-trees: free created cache entries

2013-05-30 Thread Felipe Contreras
We created them, and nobody else is going to destroy them.

Signed-off-by: Felipe Contreras 
---
 unpack-trees.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/unpack-trees.c b/unpack-trees.c
index eff2944..9f19d01 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -590,8 +590,16 @@ static int unpack_nondirectories(int n, unsigned long mask,
src[i + o->merge] = create_ce_entry(info, names + i, stage);
}
 
-   if (o->merge)
-   return call_unpack_fn(src, o);
+   if (o->merge) {
+   int ret = call_unpack_fn(src, o);
+   for (i = 0; i < n; i++) {
+   struct cache_entry *ce = src[i + o->merge];
+   if (!ce || ce == o->df_conflict_entry)
+   continue;
+   free(ce);
+   }
+   return ret;
+   }
 
for (i = 0; i < n; i++)
if (src[i] && src[i] != o->df_conflict_entry)
-- 
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