summaryrefslogtreecommitdiff
path: root/sfeed_frames.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_frames.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_frames.c')
-rw-r--r--sfeed_frames.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/sfeed_frames.c b/sfeed_frames.c
index dd50de1..972f9ce 100644
--- a/sfeed_frames.c
+++ b/sfeed_frames.c
@@ -8,7 +8,7 @@
#include "util.h"
-static struct feed **feeds;
+static struct feed *feeds;
static char *line;
static size_t linesize;
static time_t comparetime;
@@ -82,7 +82,7 @@ main(int argc, char *argv[])
if (pledge("stdio rpath wpath cpath", 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)
@@ -111,20 +111,16 @@ main(int argc, char *argv[])
"<body class=\"frame\"><div id=\"items\">", fpitems);
if (argc == 1) {
- if (!(feeds[0] = calloc(1, sizeof(struct feed))))
- err(1, "calloc");
- feeds[0]->name = "";
- printfeed(fpitems, stdin, feeds[0]);
+ feeds[0].name = "";
+ printfeed(fpitems, stdin, &feeds[0]);
} 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(fpitems, fp, feeds[i - 1]);
+ printfeed(fpitems, fp, &feeds[i - 1]);
if (ferror(fp))
err(1, "ferror: %s", argv[i]);
fclose(fp);
@@ -142,7 +138,7 @@ main(int argc, char *argv[])
"<body class=\"frame\">\n<div id=\"sidebar\">\n", fpmenu);
for (i = 1; i < argc; i++) {
- f = feeds[i - 1];
+ f = &feeds[i - 1];
if (f->totalnew)
fputs("<a class=\"n\" href=\"items.html#", fpmenu);
else