@matheusbsbs / matheus-bagliano / commits / e7d06a4b70
Fork 0

Remove unnecessary null pointer checks in fast-import.

There is no need to check for a NULL pointer before invoking free(), the runtime library automatically performs this check anyway and does nothing if a NULL pointer is supplied. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Feb 6, 2007 at 12:05 UTC e7d06a4b702463f13371eed92ba790b8c527dd76
1 file changed +5 -10
fast-import.c
+5 -10
@@ -969,10 +969,9 @@ static int store_object(
969 pack_size += s.total_out;
970
971 free(out);
972 - if (delta)
973 - free(delta);
972 + free(delta);
973 if (last) {
975 - if (last->data && !last->no_free)
974 + if (!last->no_free)
975 free(last->data);
976 last->data = dat;
977 last->offset = e->offset;
@@ -1521,9 +1520,7 @@ static void file_change_m(struct branch *b)
1520 }
1521
1522 tree_content_set(&b->branch_tree, p, sha1, S_IFREG | mode);
1524 -
1525 - if (p_uq)
1526 - free(p_uq);
1523 + free(p_uq);
1524 }
1525
1526 static void file_change_d(struct branch *b)
@@ -1539,8 +1536,7 @@ static void file_change_d(struct branch *b)
1536 p = p_uq;
1537 }
1538 tree_content_remove(&b->branch_tree, p);
1542 - if (p_uq)
1543 - free(p_uq);
1539 + free(p_uq);
1540 }
1541
1542 static void cmd_from(struct branch *b)
@@ -1719,8 +1715,7 @@ static void cmd_new_commit(void)
1715 sp += sprintf(sp, "%s\n\n", committer);
1716 memcpy(sp, msg, msglen);
1717 sp += msglen;
1722 - if (author)
1723 - free(author);
1718 + free(author);
1719 free(committer);
1720 free(msg);
1721