summaryrefslogtreecommitdiffstats
path: root/contrib/binutils/libiberty/make-temp-file.c
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2010-10-21 19:11:14 +0000
committerdim <dim@FreeBSD.org>2010-10-21 19:11:14 +0000
commit844d5c9852c83cc56dccdc017c27f2bfc0928f05 (patch)
tree506464413c40d2c6a4a46d04892a9415cb886522 /contrib/binutils/libiberty/make-temp-file.c
parentacc1b913a3297e19f9ffe7d2b7b8a3142926d3b4 (diff)
parent0acbbeece75076693a5c54ce4d376aa9f021b4e3 (diff)
downloadFreeBSD-src-844d5c9852c83cc56dccdc017c27f2bfc0928f05.zip
FreeBSD-src-844d5c9852c83cc56dccdc017c27f2bfc0928f05.tar.gz
Merge ^vendor/binutils/dist@214082 into contrib/binutils.
Diffstat (limited to 'contrib/binutils/libiberty/make-temp-file.c')
-rw-r--r--contrib/binutils/libiberty/make-temp-file.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/contrib/binutils/libiberty/make-temp-file.c b/contrib/binutils/libiberty/make-temp-file.c
index 8833504..5e21414 100644
--- a/contrib/binutils/libiberty/make-temp-file.c
+++ b/contrib/binutils/libiberty/make-temp-file.c
@@ -14,8 +14,8 @@ Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with libiberty; see the file COPYING.LIB. If not,
-write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
+write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
+Boston, MA 02110-1301, USA. */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -43,7 +43,7 @@ Boston, MA 02111-1307, USA. */
#endif
#include "libiberty.h"
-extern int mkstemps PARAMS ((char *, int));
+extern int mkstemps (char *, int);
/* '/' works just fine on MS-DOS based systems. */
#ifndef DIR_SEPARATOR
@@ -61,11 +61,10 @@ extern int mkstemps PARAMS ((char *, int));
If success, DIR is returned.
Otherwise NULL is returned. */
-static inline const char *try PARAMS ((const char *, const char *));
+static inline const char *try_dir (const char *, const char *);
static inline const char *
-try (dir, base)
- const char *dir, *base;
+try_dir (const char *dir, const char *base)
{
if (base != 0)
return base;
@@ -95,7 +94,7 @@ files in.
*/
char *
-choose_tmpdir ()
+choose_tmpdir (void)
{
const char *base = 0;
char *tmpdir;
@@ -104,18 +103,18 @@ choose_tmpdir ()
if (memoized_tmpdir)
return memoized_tmpdir;
- base = try (getenv ("TMPDIR"), base);
- base = try (getenv ("TMP"), base);
- base = try (getenv ("TEMP"), base);
+ base = try_dir (getenv ("TMPDIR"), base);
+ base = try_dir (getenv ("TMP"), base);
+ base = try_dir (getenv ("TEMP"), base);
#ifdef P_tmpdir
- base = try (P_tmpdir, base);
+ base = try_dir (P_tmpdir, base);
#endif
/* Try /var/tmp, /usr/tmp, then /tmp. */
- base = try (vartmp, base);
- base = try (usrtmp, base);
- base = try (tmp, base);
+ base = try_dir (vartmp, base);
+ base = try_dir (usrtmp, base);
+ base = try_dir (tmp, base);
/* If all else fails, use the current directory! */
if (base == 0)
@@ -124,7 +123,7 @@ choose_tmpdir ()
/* Append DIR_SEPARATOR to the directory we've chosen
and return it. */
len = strlen (base);
- tmpdir = xmalloc (len + 2);
+ tmpdir = XNEWVEC (char, len + 2);
strcpy (tmpdir, base);
tmpdir[len] = DIR_SEPARATOR;
tmpdir[len+1] = '\0';
@@ -146,8 +145,7 @@ string is @code{malloc}ed, and the temporary file has been created.
*/
char *
-make_temp_file (suffix)
- const char *suffix;
+make_temp_file (const char *suffix)
{
const char *base = choose_tmpdir ();
char *temp_filename;
@@ -160,7 +158,7 @@ make_temp_file (suffix)
base_len = strlen (base);
suffix_len = strlen (suffix);
- temp_filename = xmalloc (base_len
+ temp_filename = XNEWVEC (char, base_len
+ TEMP_FILE_LEN
+ suffix_len + 1);
strcpy (temp_filename, base);
OpenPOWER on IntegriCloud