summaryrefslogtreecommitdiff
path: root/lib/Support/SystemUtils.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-06-16 22:29:09 +0000
committerChris Lattner <sabre@nondot.org>2003-06-16 22:29:09 +0000
commit2eb9a257c86d6194ec572d8556f86af97452bebe (patch)
tree15c154d1432a5dd80f68240e76685ef6793b0ff8 /lib/Support/SystemUtils.cpp
parent5b1688d73be263590c25ca210efa4ebee7534cea (diff)
downloadllvm-2eb9a257c86d6194ec572d8556f86af97452bebe.tar.gz
llvm-2eb9a257c86d6194ec572d8556f86af97452bebe.tar.bz2
llvm-2eb9a257c86d6194ec572d8556f86af97452bebe.tar.xz
Actually, change it to use explicit new/delete, which is more likely to be
optimized INTO an alloca git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6727 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/SystemUtils.cpp')
-rw-r--r--lib/Support/SystemUtils.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/Support/SystemUtils.cpp b/lib/Support/SystemUtils.cpp
index 6ecaf2b987..51f3d18354 100644
--- a/lib/Support/SystemUtils.cpp
+++ b/lib/Support/SystemUtils.cpp
@@ -10,7 +10,6 @@
#include <fstream>
#include <iostream>
#include <cstdlib>
-#include <vector>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -33,13 +32,13 @@ std::string getUniqueFilename(const std::string &FilenameBase) {
return FilenameBase; // Couldn't open the file? Use it!
// Create a pattern for mkstemp...
- std::vector<char> FNBuffer(FilenameBase.size()+8);
- strcpy(&FNBuffer[0], FilenameBase.c_str());
- strcpy(&FNBuffer[FilenameBase.size()], "-XXXXXX");
+ char *FNBuffer = new char[FilenameBase.size()+8];
+ strcpy(FNBuffer, FilenameBase.c_str());
+ strcpy(FNBuffer+FilenameBase.size(), "-XXXXXX");
// Agree on a temporary file name to use....
int TempFD;
- if ((TempFD = mkstemp(&FNBuffer[0])) == -1) {
+ if ((TempFD = mkstemp(FNBuffer)) == -1) {
std::cerr << "bugpoint: ERROR: Cannot create temporary file in the current "
<< " directory!\n";
exit(1);
@@ -48,7 +47,9 @@ std::string getUniqueFilename(const std::string &FilenameBase) {
// We don't need to hold the temp file descriptor... we will trust that noone
// will overwrite/delete the file while we are working on it...
close(TempFD);
- return std::string(&FNBuffer[0]);
+ std::string Result(FNBuffer);
+ delete[] FNBuffer;
+ return Result;
}
/// isExecutableFile - This function returns true if the filename specified