column: do not include pager.c
[gitweb.git] / tree-diff.c
index 6a960f569cc1ae59f0b48009cee93449a02ebc97..bd6d65a40920a547b9f27512e31341231273fa75 100644 (file)
@@ -132,7 +132,7 @@ static int emit_diff_first_parent_only(struct diff_options *opt, struct combine_
  */
 static struct combine_diff_path *path_appendnew(struct combine_diff_path *last,
        int nparent, const struct strbuf *base, const char *path, int pathlen,
-       unsigned mode, const unsigned char *sha1)
+       unsigned mode, const struct object_id *oid)
 {
        struct combine_diff_path *p;
        size_t len = st_add(base->len, pathlen);
@@ -141,8 +141,7 @@ static struct combine_diff_path *path_appendnew(struct combine_diff_path *last,
        /* if last->next is !NULL - it is a pre-allocated memory, we can reuse */
        p = last->next;
        if (p && (alloclen > (intptr_t)p->next)) {
-               free(p);
-               p = NULL;
+               FREE_AND_NULL(p);
        }
 
        if (!p) {
@@ -162,7 +161,7 @@ static struct combine_diff_path *path_appendnew(struct combine_diff_path *last,
        memcpy(p->path + base->len, path, pathlen);
        p->path[len] = 0;
        p->mode = mode;
-       hashcpy(p->oid.hash, sha1 ? sha1 : null_sha1);
+       oidcpy(&p->oid, oid ? oid : &null_oid);
 
        return p;
 }
@@ -221,7 +220,7 @@ static struct combine_diff_path *emit_path(struct combine_diff_path *p,
        if (emitthis) {
                int keep;
                struct combine_diff_path *pprev = p;
-               p = path_appendnew(p, nparent, base, path, pathlen, mode, oid ? oid->hash : NULL);
+               p = path_appendnew(p, nparent, base, path, pathlen, mode, oid);
 
                for (i = 0; i < nparent; ++i) {
                        /*
@@ -559,8 +558,7 @@ struct combine_diff_path *diff_tree_paths(
         * (see path_appendnew() for details about why)
         */
        if (p->next) {
-               free(p->next);
-               p->next = NULL;
+               FREE_AND_NULL(p->next);
        }
 
        return p;