Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/pkg_install/info save another call to allocate spac...



details:   https://anonhg.NetBSD.org/src/rev/bd39e60db2d4
branches:  trunk
changeset: 487391:bd39e60db2d4
user:      hubertf <hubertf%NetBSD.org@localhost>
date:      Wed Jun 07 03:17:10 2000 +0000

description:
save another call to allocate space on the stack for something that's
definitely going to end up there.

diffstat:

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

diffs (36 lines):

diff -r d0c276de5bba -r bd39e60db2d4 usr.sbin/pkg_install/info/main.c
--- a/usr.sbin/pkg_install/info/main.c  Wed Jun 07 02:16:06 2000 +0000
+++ b/usr.sbin/pkg_install/info/main.c  Wed Jun 07 03:17:10 2000 +0000
@@ -1,11 +1,11 @@
-/*     $NetBSD: main.c,v 1.21 2000/05/11 14:13:13 hubertf Exp $        */
+/*     $NetBSD: main.c,v 1.22 2000/06/07 03:17:10 hubertf Exp $        */
 
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char *rcsid = "from FreeBSD Id: main.c,v 1.14 1997/10/08 07:47:26 charnier Exp";
 #else
-__RCSID("$NetBSD: main.c,v 1.21 2000/05/11 14:13:13 hubertf Exp $");
+__RCSID("$NetBSD: main.c,v 1.22 2000/06/07 03:17:10 hubertf Exp $");
 #endif
 #endif
 
@@ -65,16 +65,13 @@
 find_fn(const char *pkg, char *data)
 {
        lpkg_t *lpp;
-       char *fn;
+       char fn[FILENAME_MAX];
 
-       asprintf(&fn, "%s/%s", _pkgdb_getPKGDB_DIR(), pkg);
-       if (fn == NULL)
-               errx(1, "Out of memory while scanning pkgs.");
+       snprintf(fn, sizeof(fn), "%s/%s", _pkgdb_getPKGDB_DIR(), pkg);
        if (!isfile(fn)) {      /* might as well use sanity_check() */
                lpp = alloc_lpkg(pkg);
                TAILQ_INSERT_TAIL(&pkgs, lpp, lp_link);
        }
-       free(fn);
 
        return 0;
 }



Home | Main Index | Thread Index | Old Index