Module Name: src
Committed By: roy
Date: Tue May 16 09:19:49 UTC 2017
Modified Files:
src/lib/libterminfo: term.c
Log Message:
Don't bother allocating space for the database name, just print
directly to the static buffer storage.
To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/lib/libterminfo/term.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libterminfo/term.c
diff -u src/lib/libterminfo/term.c:1.23 src/lib/libterminfo/term.c:1.24
--- src/lib/libterminfo/term.c:1.23 Tue May 16 08:52:14 2017
+++ src/lib/libterminfo/term.c Tue May 16 09:19:48 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: term.c,v 1.23 2017/05/16 08:52:14 roy Exp $ */
+/* $NetBSD: term.c,v 1.24 2017/05/16 09:19:48 roy Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: term.c,v 1.23 2017/05/16 08:52:14 roy Exp $");
+__RCSID("$NetBSD: term.c,v 1.24 2017/05/16 09:19:48 roy Exp $");
#include <sys/stat.h>
@@ -46,7 +46,7 @@ __RCSID("$NetBSD: term.c,v 1.23 2017/05/
#define _PATH_TERMINFO "/usr/share/misc/terminfo"
-static char database[PATH_MAX];
+static char __ti_database[PATH_MAX];
const char *_ti_database;
/* Include a generated list of pre-compiled terminfo descriptions. */
@@ -247,16 +247,13 @@ _ti_dbgetterm(TERMINAL *term, const char
{
struct cdbr *db;
const void *data;
- char *db_name;
const uint8_t *data8;
size_t len, klen;
int r;
- if (asprintf(&db_name, "%s.cdb", path) < 0)
+ if (snprintf(__ti_database, sizeof(__ti_database), "%s.cdb", path) < 0)
return -1;
-
- db = cdbr_open(db_name, CDBR_DEFAULT);
- free(db_name);
+ db = cdbr_open(__ti_database, CDBR_DEFAULT);
if (db == NULL)
return -1;
@@ -284,8 +281,7 @@ _ti_dbgetterm(TERMINAL *term, const char
else if (memcmp(data8 + 3, name, klen))
goto fail;
- strlcpy(database, path, sizeof(database));
- _ti_database = database;
+ _ti_database = __ti_database;
r = _ti_readterm(term, data, len, flags);
cdbr_close(db);
@@ -363,7 +359,7 @@ _ti_findterm(TERMINAL *term, const char
_DIAGASSERT(term != NULL);
_DIAGASSERT(name != NULL);
- database[0] = '\0';
+ __ti_database[0] = '\0';
_ti_database = NULL;
r = 0;