Module Name: src
Committed By: abhinav
Date: Mon May 1 05:52:33 UTC 2017
Modified Files:
src/usr.sbin/makemandb: makemandb.c
Log Message:
Avoid copying strings where it is not needed.
To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/usr.sbin/makemandb/makemandb.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.sbin/makemandb/makemandb.c
diff -u src/usr.sbin/makemandb/makemandb.c:1.50 src/usr.sbin/makemandb/makemandb.c:1.51
--- src/usr.sbin/makemandb/makemandb.c:1.50 Sun Apr 30 08:41:18 2017
+++ src/usr.sbin/makemandb/makemandb.c Mon May 1 05:52:33 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: makemandb.c,v 1.50 2017/04/30 08:41:18 abhinav Exp $ */
+/* $NetBSD: makemandb.c,v 1.51 2017/05/01 05:52:33 abhinav Exp $ */
/*
* Copyright (c) 2011 Abhinav Upadhyay <[email protected]>
* Copyright (c) 2011 Kristaps Dzonsons <[email protected]>
@@ -17,7 +17,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: makemandb.c,v 1.50 2017/04/30 08:41:18 abhinav Exp $");
+__RCSID("$NetBSD: makemandb.c,v 1.51 2017/05/01 05:52:33 abhinav Exp $");
#include <sys/stat.h>
#include <sys/types.h>
@@ -331,7 +331,7 @@ main(int argc, char *argv[])
{
FILE *file;
const char *sqlstr, *manconf = NULL;
- char *line, *command, *parent;
+ char *line, *command;
char *errmsg;
int ch;
struct mparse *mp;
@@ -450,12 +450,9 @@ main(int argc, char *argv[])
while ((len = getline(&line, &linesize, file)) != -1) {
/* Replace the new line character at the end of string with '\0' */
line[len - 1] = '\0';
- parent = estrdup(line);
- char *pdir = estrdup(dirname(parent));
- free(parent);
+ char *pdir = dirname(line);
/* Traverse the man page directories and parse the pages */
traversedir(pdir, line, db, mp);
- free(pdir);
}
free(line);