Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/makemandb Avoid copying strings where it is not nee...



details:   https://anonhg.NetBSD.org/src/rev/96305ba681b7
branches:  trunk
changeset: 823656:96305ba681b7
user:      abhinav <abhinav%NetBSD.org@localhost>
date:      Mon May 01 05:52:33 2017 +0000

description:
Avoid copying strings where it is not needed.

diffstat:

 usr.sbin/makemandb/makemandb.c |  11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)

diffs (41 lines):

diff -r ee755c698ed2 -r 96305ba681b7 usr.sbin/makemandb/makemandb.c
--- a/usr.sbin/makemandb/makemandb.c    Mon May 01 05:28:00 2017 +0000
+++ b/usr.sbin/makemandb/makemandb.c    Mon May 01 05:52:33 2017 +0000
@@ -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 <er.abhinav.upadhyay%gmail.com@localhost>
  * Copyright (c) 2011 Kristaps Dzonsons <kristaps%bsd.lv@localhost>
@@ -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 @@
 {
        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 @@
        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);
 



Home | Main Index | Thread Index | Old Index