about summary refs log tree commit diff
path: root/Src/hist.c
diff options
context:
space:
mode:
authorWayne Davison <wayned@users.sourceforge.net>2004-10-21 00:33:50 +0000
committerWayne Davison <wayned@users.sourceforge.net>2004-10-21 00:33:50 +0000
commit3ccc3e4bdcaed42c72e6b22c1306518458778541 (patch)
treea420f6a525ed82316b35f9d349c1736d6073251e /Src/hist.c
parent65729f55704b22dbe781bd826a852bfe48b3e8e1 (diff)
downloadzsh-3ccc3e4bdcaed42c72e6b22c1306518458778541.tar.gz
zsh-3ccc3e4bdcaed42c72e6b22c1306518458778541.tar.xz
zsh-3ccc3e4bdcaed42c72e6b22c1306518458778541.zip
Use the new gettempfile() function.
Diffstat (limited to 'Src/hist.c')
-rw-r--r--Src/hist.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/Src/hist.c b/Src/hist.c
index 3f7927010..4e1a23c2a 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -2137,8 +2137,7 @@ lockhistfile(char *fn, int keep_trying)
 
 	lockfile = bicat(unmeta(fn), ".LOCK");
 #ifdef HAVE_LINK
-	tmpfile = gettempname(fn, 0);
-	if ((fd = open(tmpfile, O_WRONLY|O_CREAT|O_EXCL, 0644)) >= 0) {
+	if ((fd = gettempfile(fn, 0, &tmpfile)) >= 0) {
 	    FILE *out = fdopen(fd, "w");
 	    if (out) {
 		fprintf(out, "%ld %s\n", (long)getpid(), getsparam("HOST"));
@@ -2163,8 +2162,8 @@ lockhistfile(char *fn, int keep_trying)
 		break;
 	    }
 	    unlink(tmpfile);
+	    free(tmpfile);
 	}
-	free(tmpfile);
 #else /* not HAVE_LINK */
 	while ((fd = open(lockfile, O_WRONLY|O_CREAT|O_EXCL, 0644)) < 0) {
 	    if (errno != EEXIST || !keep_trying)