is not used by anything performance sensitive, so just use std::string.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91528
91177308-0d34-0410-b5e6-
96231b3b80d8
//=== is guaranteed to work on *all* UNIX variants.
//===----------------------------------------------------------------------===//
//=== is guaranteed to work on *all* UNIX variants.
//===----------------------------------------------------------------------===//
-#include "llvm/ADT/SmallVector.h"
#include "Unix.h"
#if HAVE_SYS_STAT_H
#include <sys/stat.h>
#include "Unix.h"
#if HAVE_SYS_STAT_H
#include <sys/stat.h>
// Append an XXXXXX pattern to the end of the file for use with mkstemp,
// mktemp or our own implementation.
// Append an XXXXXX pattern to the end of the file for use with mkstemp,
// mktemp or our own implementation.
- SmallVector<char, 128> Buf;
- Buf.resize(path.size()+8);
- char *FNBuffer = Buf.data();
- path.copy(FNBuffer,path.size());
- strcpy(FNBuffer+path.size(), "/XXXXXX");
- strcpy(FNBuffer+path.size(), "-XXXXXX");
#if defined(HAVE_MKSTEMP)
int TempFD;
#if defined(HAVE_MKSTEMP)
int TempFD;
- if ((TempFD = mkstemp(FNBuffer)) == -1)
+ if ((TempFD = mkstemp((char*)Buf.c_str())) == -1)
return MakeErrMsg(ErrMsg, path + ": can't make unique filename");
// We don't need to hold the temp file descriptor... we will trust that no one
return MakeErrMsg(ErrMsg, path + ": can't make unique filename");
// We don't need to hold the temp file descriptor... we will trust that no one
close(TempFD);
// Save the name
close(TempFD);
// Save the name
#elif defined(HAVE_MKTEMP)
// If we don't have mkstemp, use the old and obsolete mktemp function.
#elif defined(HAVE_MKTEMP)
// If we don't have mkstemp, use the old and obsolete mktemp function.
- if (mktemp(FNBuffer) == 0)
+ if (mktemp(Buf.c_str()) == 0)
return MakeErrMsg(ErrMsg, path + ": can't make unique filename");
// Save the name
return MakeErrMsg(ErrMsg, path + ": can't make unique filename");
// Save the name
#else
// Okay, looks like we have to do it all by our lonesome.
static unsigned FCounter = 0;
unsigned offset = path.size() + 1;
#else
// Okay, looks like we have to do it all by our lonesome.
static unsigned FCounter = 0;
unsigned offset = path.size() + 1;
- while ( FCounter < 999999 && exists()) {
- sprintf(FNBuffer+offset,"%06u",++FCounter);
- path = FNBuffer;
+ while (FCounter < 999999 && exists()) {
+ sprintf(Buf.data()+offset, "%06u", ++FCounter);
+ path = Buf;
}
if (FCounter > 999999)
return MakeErrMsg(ErrMsg,
}
if (FCounter > 999999)
return MakeErrMsg(ErrMsg,