diff options
| author | roy <roy@NetBSD.org> | 2017-05-16 09:19:48 +0000 |
|---|---|---|
| committer | roy <roy@NetBSD.org> | 2017-05-16 09:19:48 +0000 |
| commit | ba71597a971a194cd254162f32fb3d4eae321ca5 (patch) | |
| tree | 972e885cc6ecd4f961a048ed4bb03c0ed859effa /lib/libterminfo | |
| parent | d628c7a1f42e6e629ce42eb3f6244bac7db20cec (diff) | |
Don't bother allocating space for the database name, just print
directly to the static buffer storage.
Diffstat (limited to 'lib/libterminfo')
| -rw-r--r-- | lib/libterminfo/term.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/lib/libterminfo/term.c b/lib/libterminfo/term.c index 9bea2020bac..410e4e41788 100644 --- a/lib/libterminfo/term.c +++ b/lib/libterminfo/term.c @@ -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/16 08:52:14 roy Exp $"); #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 *path, const char *name, int flags) { 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 *path, const char *name, int flags) 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 *name, int flags) _DIAGASSERT(term != NULL); _DIAGASSERT(name != NULL); - database[0] = '\0'; + __ti_database[0] = '\0'; _ti_database = NULL; r = 0; |
