summaryrefslogtreecommitdiffstats
path: root/man_term.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-10-27 08:49:44 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-10-27 08:49:44 +0000
commitc6fa100a886693167f543f9b59fbc85e46faa49c (patch)
tree0898a4fae069e53223c8037f15f122d6831fa263 /man_term.c
parent7e736e832ab3af50731a6052e3a35a687fa8b3a4 (diff)
downloadmandoc-c6fa100a886693167f543f9b59fbc85e46faa49c.tar.gz
Removed dynamic allocations of header/footer data.
Diffstat (limited to 'man_term.c')
-rw-r--r--man_term.c23
1 files changed, 6 insertions, 17 deletions
diff --git a/man_term.c b/man_term.c
index 40d3d087..8ffa7cff 100644
--- a/man_term.c
+++ b/man_term.c
@@ -939,25 +939,18 @@ print_man_foot(struct termp *p, const struct man_meta *meta)
static void
-print_man_head(struct termp *p, const struct man_meta *meta)
+print_man_head(struct termp *p, const struct man_meta *m)
{
- char *buf, *title;
+ char buf[BUFSIZ], title[BUFSIZ];
p->rmargin = p->maxrmargin;
p->offset = 0;
+ buf[0] = title[0] = '\0';
- if (NULL == (buf = malloc(p->rmargin)))
- err(EXIT_FAILURE, "malloc");
- if (NULL == (title = malloc(p->rmargin)))
- err(EXIT_FAILURE, "malloc");
+ if (m->vol)
+ strlcpy(buf, m->vol, BUFSIZ);
- if (meta->vol)
- (void)strlcpy(buf, meta->vol, p->rmargin);
- else
- *buf = 0;
-
- (void)snprintf(title, p->rmargin, "%s(%d)",
- meta->title, meta->msec);
+ snprintf(title, BUFSIZ, "%s(%d)", m->title, m->msec);
p->offset = 0;
p->rmargin = (p->maxrmargin - strlen(buf) + 1) / 2;
@@ -984,8 +977,4 @@ print_man_head(struct termp *p, const struct man_meta *meta)
p->rmargin = p->maxrmargin;
p->offset = 0;
p->flags &= ~TERMP_NOSPACE;
-
- free(title);
- free(buf);
}
-