Remove usage of alloca

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6726 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2003-06-16 22:22:11 +00:00
parent 0bf9476701
commit 5b1688d73b
3 changed files with 18 additions and 18 deletions

View File

@ -10,7 +10,7 @@
#include <fstream>
#include <iostream>
#include <cstdlib>
#include "Support/Alloca.h"
#include <vector>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@ -33,13 +33,13 @@ std::string getUniqueFilename(const std::string &FilenameBase) {
return FilenameBase; // Couldn't open the file? Use it!
// Create a pattern for mkstemp...
char *FNBuffer = (char*)alloca(FilenameBase.size()+8);
strcpy(FNBuffer, FilenameBase.c_str());
strcpy(FNBuffer+FilenameBase.size(), "-XXXXXX");
std::vector<char> FNBuffer(FilenameBase.size()+8);
strcpy(&FNBuffer[0], FilenameBase.c_str());
strcpy(&FNBuffer[FilenameBase.size()], "-XXXXXX");
// Agree on a temporary file name to use....
int TempFD;
if ((TempFD = mkstemp(FNBuffer)) == -1) {
if ((TempFD = mkstemp(&FNBuffer[0])) == -1) {
std::cerr << "bugpoint: ERROR: Cannot create temporary file in the current "
<< " directory!\n";
exit(1);
@ -48,7 +48,7 @@ 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 FNBuffer;
return std::string(&FNBuffer[0]);
}
/// isExecutableFile - This function returns true if the filename specified

View File

@ -10,7 +10,7 @@
#include <fstream>
#include <iostream>
#include <cstdlib>
#include "Support/Alloca.h"
#include <vector>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@ -33,13 +33,13 @@ std::string getUniqueFilename(const std::string &FilenameBase) {
return FilenameBase; // Couldn't open the file? Use it!
// Create a pattern for mkstemp...
char *FNBuffer = (char*)alloca(FilenameBase.size()+8);
strcpy(FNBuffer, FilenameBase.c_str());
strcpy(FNBuffer+FilenameBase.size(), "-XXXXXX");
std::vector<char> FNBuffer(FilenameBase.size()+8);
strcpy(&FNBuffer[0], FilenameBase.c_str());
strcpy(&FNBuffer[FilenameBase.size()], "-XXXXXX");
// Agree on a temporary file name to use....
int TempFD;
if ((TempFD = mkstemp(FNBuffer)) == -1) {
if ((TempFD = mkstemp(&FNBuffer[0])) == -1) {
std::cerr << "bugpoint: ERROR: Cannot create temporary file in the current "
<< " directory!\n";
exit(1);
@ -48,7 +48,7 @@ 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 FNBuffer;
return std::string(&FNBuffer[0]);
}
/// isExecutableFile - This function returns true if the filename specified

View File

@ -10,7 +10,7 @@
#include <fstream>
#include <iostream>
#include <cstdlib>
#include "Support/Alloca.h"
#include <vector>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@ -33,13 +33,13 @@ std::string getUniqueFilename(const std::string &FilenameBase) {
return FilenameBase; // Couldn't open the file? Use it!
// Create a pattern for mkstemp...
char *FNBuffer = (char*)alloca(FilenameBase.size()+8);
strcpy(FNBuffer, FilenameBase.c_str());
strcpy(FNBuffer+FilenameBase.size(), "-XXXXXX");
std::vector<char> FNBuffer(FilenameBase.size()+8);
strcpy(&FNBuffer[0], FilenameBase.c_str());
strcpy(&FNBuffer[FilenameBase.size()], "-XXXXXX");
// Agree on a temporary file name to use....
int TempFD;
if ((TempFD = mkstemp(FNBuffer)) == -1) {
if ((TempFD = mkstemp(&FNBuffer[0])) == -1) {
std::cerr << "bugpoint: ERROR: Cannot create temporary file in the current "
<< " directory!\n";
exit(1);
@ -48,7 +48,7 @@ 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 FNBuffer;
return std::string(&FNBuffer[0]);
}
/// isExecutableFile - This function returns true if the filename specified