summaryrefslogtreecommitdiff
path: root/sfeed_html.c
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2020-06-21 18:08:41 +0200
committerHiltjo Posthuma <hiltjo@codemadness.org>2020-06-21 18:08:41 +0200
commit1b14e601434435f48dfe1027a117c2af3dac325b (patch)
tree77d1446dd002f67c48567cac224b22260ae96355 /sfeed_html.c
parentb4830a4a3a98874293e20b309e083a144c1b3609 (diff)
sfeed_html/sfeed_frames: simplify struct feed allocation
There's no need for a dynamic struct feed **. The required size is known (argc). Just allocate it in one go.
Diffstat (limited to 'sfeed_html.c')
-rw-r--r--sfeed_html.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/sfeed_html.c b/sfeed_html.c
index caac47e..97318af 100644
--- a/sfeed_html.c
+++ b/sfeed_html.c
@@ -8,7 +8,7 @@
#include "util.h"
-static struct feed **feeds;
+static struct feed *feeds;
static int showsidebar;
static char *line;
static size_t linesize;
@@ -83,7 +83,7 @@ main(int argc, char *argv[])
if (pledge(argc == 1 ? "stdio" : "stdio rpath", NULL) == -1)
err(1, "pledge");
- if (!(feeds = calloc(argc, sizeof(struct feed *))))
+ if (!(feeds = calloc(argc, sizeof(struct feed))))
err(1, "calloc");
if ((comparetime = time(NULL)) == -1)
err(1, "time");
@@ -106,21 +106,17 @@ main(int argc, char *argv[])
fputs("\t\t<div id=\"items\" class=\"nosidebar\">\n", stdout);
if (argc == 1) {
- if (!(feeds[0] = calloc(1, sizeof(struct feed))))
- err(1, "calloc");
- feeds[0]->name = "";
- printfeed(stdin, feeds[0]);
+ feeds[0].name = "";
+ printfeed(stdin, &feeds[0]);
if (ferror(stdin))
err(1, "ferror: <stdin>:");
} else {
for (i = 1; i < argc; i++) {
- if (!(feeds[i - 1] = calloc(1, sizeof(struct feed))))
- err(1, "calloc");
name = ((name = strrchr(argv[i], '/'))) ? name + 1 : argv[i];
- feeds[i - 1]->name = name;
+ feeds[i - 1].name = name;
if (!(fp = fopen(argv[i], "r")))
err(1, "fopen: %s", argv[i]);
- printfeed(fp, feeds[i - 1]);
+ printfeed(fp, &feeds[i - 1]);
if (ferror(fp))
err(1, "ferror: %s", argv[i]);
fclose(fp);
@@ -132,7 +128,7 @@ main(int argc, char *argv[])
fputs("\t<div id=\"sidebar\">\n\t\t<ul>\n", stdout);
for (i = 1; i < argc; i++) {
- f = feeds[i - 1];
+ f = &feeds[i - 1];
if (f->totalnew > 0)
fputs("<li class=\"n\"><a href=\"#", stdout);
else