aboutsummaryrefslogtreecommitdiff
path: root/stdio-common/tempnam.c
diff options
context:
space:
mode:
Diffstat (limited to 'stdio-common/tempnam.c')
-rw-r--r--stdio-common/tempnam.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/stdio-common/tempnam.c b/stdio-common/tempnam.c
index 987fbbbabe..8683643c76 100644
--- a/stdio-common/tempnam.c
+++ b/stdio-common/tempnam.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1993, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1993, 1996, 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -16,13 +16,9 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#include <errno.h>
-#include <stddef.h>
#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
-
/* Generate a unique temporary filename using up to five characters of PFX
if it is not NULL. The directory to put this file in is searched for
as follows: First the environment variable "TMPDIR" is checked.
@@ -34,17 +30,12 @@ char *
tempnam (const char *dir, const char *pfx)
{
char buf[FILENAME_MAX];
- size_t len;
- char *s;
- char *t = __stdio_gen_tempname (buf, sizeof (buf), dir, pfx, 1,
- &len, (FILE **) NULL, 0);
- if (t == NULL)
+ if (__path_search (buf, FILENAME_MAX, dir, pfx))
return NULL;
- s = (char *) malloc (len);
- if (s == NULL)
+ if (__gen_tempname (buf, 0, 0))
return NULL;
- return (char *) memcpy (s, t, len);
+ return strdup (buf);
}