Code

Fix grammar nits in documentation and in code comments.
[git.git] / builtin-blame.c
index c158d319dce78c6b1f0cfeffd91ee565a2d14eff..9b4c02e87f7ef4a20d269ab9315b6977cf7fb3fb 100644 (file)
@@ -125,11 +125,18 @@ static void origin_decref(struct origin *o)
        if (o && --o->refcnt <= 0) {
                if (o->file.ptr)
                        free(o->file.ptr);
-               memset(o, 0, sizeof(*o));
                free(o);
        }
 }
 
+static void drop_origin_blob(struct origin *o)
+{
+       if (o->file.ptr) {
+               free(o->file.ptr);
+               o->file.ptr = NULL;
+       }
+}
+
 /*
  * Each group of lines is described by a blame_entry; it can be split
  * as we pass blame to the parents.  They form a linked list in the
@@ -380,6 +387,7 @@ static struct origin *find_origin(struct scoreboard *sb,
                }
        }
        diff_flush(&diff_opts);
+       diff_tree_release_paths(&diff_opts);
        if (porigin) {
                /*
                 * Create a freestanding copy that is not part of
@@ -436,6 +444,7 @@ static struct origin *find_rename(struct scoreboard *sb,
                }
        }
        diff_flush(&diff_opts);
+       diff_tree_release_paths(&diff_opts);
        return porigin;
 }
 
@@ -532,7 +541,7 @@ static struct patch *compare_buffer(mmfile_t *file_p, mmfile_t *file_o,
        state.ret->chunks = NULL;
        state.ret->num = 0;
 
-       xdl_diff(file_p, file_o, &xpp, &xecfg, &ecb);
+       xdi_diff(file_p, file_o, &xpp, &xecfg, &ecb);
 
        if (state.ret->num) {
                struct chunk *chunk;
@@ -597,7 +606,7 @@ static void add_blame_entry(struct scoreboard *sb, struct blame_entry *e)
 
 /*
  * src typically is on-stack; we want to copy the information in it to
- * an malloced blame_entry that is already on the linked list of the
+ * a malloced blame_entry that is already on the linked list of the
  * scoreboard.  The origin of dst loses a refcnt while the origin of src
  * gains one.
  */
@@ -1157,7 +1166,7 @@ static int find_copy_in_parent(struct scoreboard *sb,
                }
        }
        diff_flush(&diff_opts);
-
+       diff_tree_release_paths(&diff_opts);
        return retval;
 }
 
@@ -1274,8 +1283,13 @@ static void pass_blame(struct scoreboard *sb, struct origin *origin, int opt)
                }
 
  finish:
-       for (i = 0; i < MAXPARENT; i++)
-               origin_decref(parent_origin[i]);
+       for (i = 0; i < MAXPARENT; i++) {
+               if (parent_origin[i]) {
+                       drop_origin_blob(parent_origin[i]);
+                       origin_decref(parent_origin[i]);
+               }
+       }
+       drop_origin_blob(origin);
 }
 
 /*