Skip to content

Commit

Permalink
commit: save the commit buffer off when parsing a commit
Browse files Browse the repository at this point in the history
object.

A fair number of the users potentially want to look at the
commit objects more closely, and if you worry about memory
leaking in certain applications, you can always do a

	free(commit->buffer);
	commit->buffer = NULL;

by hand after parsing them.
  • Loading branch information
Linus Torvalds committed May 26, 2005
1 parent e871b64 commit 3ff1fbb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions commit.c
Expand Up @@ -103,6 +103,10 @@ int parse_commit(struct commit *item)
sha1_to_hex(item->object.sha1)); sha1_to_hex(item->object.sha1));
} }
ret = parse_commit_buffer(item, buffer, size); ret = parse_commit_buffer(item, buffer, size);
if (!ret) {
item->buffer = buffer;
return 0;
}
free(buffer); free(buffer);
return ret; return ret;
} }
Expand Down
1 change: 1 addition & 0 deletions commit.h
Expand Up @@ -14,6 +14,7 @@ struct commit {
unsigned long date; unsigned long date;
struct commit_list *parents; struct commit_list *parents;
struct tree *tree; struct tree *tree;
const char *buffer;
}; };


extern const char *commit_type; extern const char *commit_type;
Expand Down

0 comments on commit 3ff1fbb

Please sign in to comment.