From b86199fb609d691b0a12761621760aa52562e195 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Mon, 29 Jan 1996 19:30:15 +0000 Subject: Set $inhibit_glue. --- db/btree/bt_open.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'db/btree') diff --git a/db/btree/bt_open.c b/db/btree/bt_open.c index f052249..503db85 100644 --- a/db/btree/bt_open.c +++ b/db/btree/bt_open.c @@ -200,7 +200,7 @@ __bt_open(fname, flags, mode, openinfo, dflags) default: goto einval; } - + if ((t->bt_fd = open(fname, flags, mode)) < 0) goto err; @@ -388,18 +388,30 @@ tmp() { sigset_t set, oset; int fd; - char *envtmp; - char path[MAXPATHLEN]; + const char *envtmp; + char *path; + static const char fmt[] = "%s/bt.XXXXXX"; + size_t n; envtmp = getenv("TMPDIR"); - (void)snprintf(path, - sizeof(path), "%s/bt.XXXXXX", envtmp ? envtmp : "/tmp"); + if (!envtmp) + envtmp = "/tmp"; + n = strlen (envtmp) + sizeof fmt; +#ifdef __GNUC__ + path = __builtin_alloca(n); +#else + path = malloc(n); +#endif + (void)snprintf(path, n, fmt, envtmp ? envtmp : "/tmp"); (void)sigfillset(&set); (void)sigprocmask(SIG_BLOCK, &set, &oset); if ((fd = mkstemp(path)) != -1) (void)unlink(path); (void)sigprocmask(SIG_SETMASK, &oset, NULL); +#ifndef __GNUC__ + free(path); +#endif return(fd); } -- cgit v1.1