aboutsummaryrefslogtreecommitdiff
path: root/graph.c
diff options
context:
space:
mode:
authorBrandon Casey <casey@nrlssc.navy.mil>2008-10-09 14:12:12 -0500
committerShawn O. Pearce <spearce@spearce.org>2008-10-12 12:36:19 -0700
commitf285a2d7ed6548666989406de8f0e7233eb84368 (patch)
tree2e422bd9ceeeb432ca03b61f91165790f0e37146 /graph.c
parent7e7abea96b8140c592a46293f5e33aae0683c7ac (diff)
downloadgit-f285a2d7ed6548666989406de8f0e7233eb84368.tar.gz
git-f285a2d7ed6548666989406de8f0e7233eb84368.tar.xz
Replace calls to strbuf_init(&foo, 0) with STRBUF_INIT initializer
Many call sites use strbuf_init(&foo, 0) to initialize local strbuf variable "foo" which has not been accessed since its declaration. These can be replaced with a static initialization using the STRBUF_INIT macro which is just as readable, saves a function call, and takes up fewer lines. Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'graph.c')
-rw-r--r--graph.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/graph.c b/graph.c
index 5f821706c..162a516ee 100644
--- a/graph.c
+++ b/graph.c
@@ -1010,14 +1010,12 @@ int graph_is_commit_finished(struct git_graph const *graph)
void graph_show_commit(struct git_graph *graph)
{
- struct strbuf msgbuf;
+ struct strbuf msgbuf = STRBUF_INIT;
int shown_commit_line = 0;
if (!graph)
return;
- strbuf_init(&msgbuf, 0);
-
while (!shown_commit_line) {
shown_commit_line = graph_next_line(graph, &msgbuf);
fwrite(msgbuf.buf, sizeof(char), msgbuf.len, stdout);
@@ -1031,12 +1029,11 @@ void graph_show_commit(struct git_graph *graph)
void graph_show_oneline(struct git_graph *graph)
{
- struct strbuf msgbuf;
+ struct strbuf msgbuf = STRBUF_INIT;
if (!graph)
return;
- strbuf_init(&msgbuf, 0);
graph_next_line(graph, &msgbuf);
fwrite(msgbuf.buf, sizeof(char), msgbuf.len, stdout);
strbuf_release(&msgbuf);
@@ -1044,12 +1041,11 @@ void graph_show_oneline(struct git_graph *graph)
void graph_show_padding(struct git_graph *graph)
{
- struct strbuf msgbuf;
+ struct strbuf msgbuf = STRBUF_INIT;
if (!graph)
return;
- strbuf_init(&msgbuf, 0);
graph_padding_line(graph, &msgbuf);
fwrite(msgbuf.buf, sizeof(char), msgbuf.len, stdout);
strbuf_release(&msgbuf);
@@ -1057,7 +1053,7 @@ void graph_show_padding(struct git_graph *graph)
int graph_show_remainder(struct git_graph *graph)
{
- struct strbuf msgbuf;
+ struct strbuf msgbuf = STRBUF_INIT;
int shown = 0;
if (!graph)
@@ -1066,7 +1062,6 @@ int graph_show_remainder(struct git_graph *graph)
if (graph_is_commit_finished(graph))
return 0;
- strbuf_init(&msgbuf, 0);
for (;;) {
graph_next_line(graph, &msgbuf);
fwrite(msgbuf.buf, sizeof(char), msgbuf.len, stdout);