summaryrefslogtreecommitdiff
path: root/curses.c
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-05-25 00:57:32 -0700
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-05-25 00:58:15 -0700
commit9edcd68e7ddcdc4deca8c07b5b1c3c59cef13255 (patch)
tree1a7a0069e8d51709238d991dc43f0323ec32bb9c /curses.c
parent9a02c0367351c311734f42ab2afe2b377ca12908 (diff)
downloaddartboat-9edcd68e7ddcdc4deca8c07b5b1c3c59cef13255.tar.gz
dartboat-9edcd68e7ddcdc4deca8c07b5b1c3c59cef13255.tar.xz
pregenerate segment names to avoid constant mallocs
Diffstat (limited to 'curses.c')
-rw-r--r--curses.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/curses.c b/curses.c
index 174a6b9..5e5d934 100644
--- a/curses.c
+++ b/curses.c
@@ -131,12 +131,10 @@ void curses_draw(struct leg *l1, struct leg *l2)
buflen += sprintf(buf + buflen, "%3d", v->points);
flushbuf(buf, &buflen, points_colour(v->points));
- for (int j = 0; j < v->n_darts; ++j) {
- char *n = segment_name(v->darts[j]);
+ for (int j = 0; j < v->n_darts; ++j)
buflen += sprintf(buf + buflen,
- j == 0 ? " %4s" :" %4s", n);
- free(n);
- }
+ j == 0 ? " %4s" : " %4s",
+ segment_name(v->darts[j]));
flushbuf(buf, &buflen, COLOR_PAIR(C_DARTS));
}