X-Git-Url: http://drtracing.org/?a=blobdiff_plain;ds=sidebyside;f=libiberty%2Fchoose-temp.c;h=49a2faaa51bb6d6c28c611e52d05f656ea25dadd;hb=fe7d6a8db01f2a71520578267df7cd2d780ececb;hp=1f5e0e50c880d3ed1f568139200cad721cd523a3;hpb=979c05d32447bf9388479ed6ef8e5665b40e5763;p=deliverable%2Fbinutils-gdb.git diff --git a/libiberty/choose-temp.c b/libiberty/choose-temp.c index 1f5e0e50c8..49a2faaa51 100644 --- a/libiberty/choose-temp.c +++ b/libiberty/choose-temp.c @@ -1,5 +1,5 @@ /* Utility to pick a temporary filename prefix. - Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1996-2020 Free Software Foundation, Inc. This file is part of the libiberty library. Libiberty is free software; you can redistribute it and/or @@ -22,6 +22,10 @@ Boston, MA 02110-1301, USA. */ #endif #include /* May get P_tmpdir. */ +#include +#ifdef HAVE_UNISTD_H +#include +#endif #ifdef HAVE_STDLIB_H #include #endif @@ -30,7 +34,6 @@ Boston, MA 02110-1301, USA. */ #endif #include "libiberty.h" -extern char *choose_tmpdir (void); /* Name of temporary file. mktemp requires 6 trailing X's. */ @@ -46,7 +49,7 @@ find one. The current directory is chosen if all else fails so the program is exited if a temporary directory can't be found (@code{mktemp} fails). The buffer for the result is obtained with @code{xmalloc}. -This function is provided for backwards compatability only. Its use is +This function is provided for backwards compatibility only. Its use is not recommended. @end deftypefn @@ -61,12 +64,11 @@ choose_temp_base (void) int len; len = strlen (base); - temp_filename = xmalloc (len + TEMP_FILE_LEN + 1); + temp_filename = XNEWVEC (char, len + TEMP_FILE_LEN + 1); strcpy (temp_filename, base); strcpy (temp_filename + len, TEMP_FILE); - mktemp (temp_filename); - if (strlen (temp_filename) == 0) + if (mktemp (temp_filename) == 0) abort (); return temp_filename; }