Skip to content

Commit 33011e7

Browse files
pcloudsgitster
authored andcommitted
trace.c: move strbuf_release() out of print_trace_line()
The function is about printing a trace line, not releasing the buffer it receives too. Move strbuf_release() back outside. This makes it easier to see how strbuf is managed. Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1fbdab2 commit 33011e7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

trace.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ static void print_trace_line(struct trace_key *key, struct strbuf *buf)
131131
{
132132
strbuf_complete_line(buf);
133133
trace_write(key, buf->buf, buf->len);
134-
strbuf_release(buf);
135134
}
136135

137136
static void trace_vprintf_fl(const char *file, int line, struct trace_key *key,
@@ -144,6 +143,7 @@ static void trace_vprintf_fl(const char *file, int line, struct trace_key *key,
144143

145144
strbuf_vaddf(&buf, format, ap);
146145
print_trace_line(key, &buf);
146+
strbuf_release(&buf);
147147
}
148148

149149
static void trace_argv_vprintf_fl(const char *file, int line,
@@ -159,6 +159,7 @@ static void trace_argv_vprintf_fl(const char *file, int line,
159159

160160
sq_quote_argv_pretty(&buf, argv);
161161
print_trace_line(&trace_default_key, &buf);
162+
strbuf_release(&buf);
162163
}
163164

164165
void trace_strbuf_fl(const char *file, int line, struct trace_key *key,
@@ -171,6 +172,7 @@ void trace_strbuf_fl(const char *file, int line, struct trace_key *key,
171172

172173
strbuf_addbuf(&buf, data);
173174
print_trace_line(key, &buf);
175+
strbuf_release(&buf);
174176
}
175177

176178
static void trace_performance_vprintf_fl(const char *file, int line,
@@ -190,6 +192,7 @@ static void trace_performance_vprintf_fl(const char *file, int line,
190192
}
191193

192194
print_trace_line(&trace_perf_key, &buf);
195+
strbuf_release(&buf);
193196
}
194197

195198
#ifndef HAVE_VARIADIC_MACROS

0 commit comments

Comments
 (0)