From 9edcd68e7ddcdc4deca8c07b5b1c3c59cef13255 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Wed, 25 May 2022 00:57:32 -0700 Subject: pregenerate segment names to avoid constant mallocs --- dartboat.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'dartboat.c') diff --git a/dartboat.c b/dartboat.c index 7061b9a..58cddfc 100644 --- a/dartboat.c +++ b/dartboat.c @@ -21,11 +21,9 @@ void test_match(int start_points) struct visit *v = l->visits + i; printf("(%2d) %3d %3d", i+1, v->points, v->rem); - for (int j = 0; j < v->n_darts; ++j) { - char *n = segment_name(v->darts[j]); - printf(j == 0 ? " %4s" :" %4s", n); - free(n); - } + for (int j = 0; j < v->n_darts; ++j) + printf(j == 0 ? " %4s" : " %4s", + segment_name(v->darts[j])); printf("\n"); } -- cgit v1.2.3-70-g09d2