about summary refs log tree commit diff
path: root/db/btree
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1996-01-29 19:30:15 +0000
committerRoland McGrath <roland@gnu.org>1996-01-29 19:30:15 +0000
commitb86199fb609d691b0a12761621760aa52562e195 (patch)
tree1516836553fe8f661a017a509b36f3604d82cd36 /db/btree
parent429ed67ba10dccfa6472bf803473fd20c0203309 (diff)
downloadglibc-b86199fb609d691b0a12761621760aa52562e195.tar.gz
glibc-b86199fb609d691b0a12761621760aa52562e195.tar.xz
glibc-b86199fb609d691b0a12761621760aa52562e195.zip
Set $inhibit_glue.
Diffstat (limited to 'db/btree')
-rw-r--r--db/btree/bt_open.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/db/btree/bt_open.c b/db/btree/bt_open.c
index f052249777..503db85274 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);
 }