llvm.org GIT mirror llvm / 3daae27
Add new MemoryBuffer::getMemBufferCopy method. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42815 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 12 years ago
2 changed file(s) with 21 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
6060 static MemoryBuffer *getMemBuffer(const char *StartPtr, const char *EndPtr,
6161 const char *BufferName = "");
6262
63 /// getMemBufferCopy - Open the specified memory range as a MemoryBuffer,
64 /// copying the contents and taking ownership of it. This has no requirements
65 /// on EndPtr[0].
66 static MemoryBuffer *getMemBufferCopy(const char *StartPtr,const char *EndPtr,
67 const char *BufferName = "");
68
6369 /// getNewMemBuffer - Allocate a new MemoryBuffer of the specified size that
6470 /// is completely initialized to zeros. Note that the caller should
6571 /// initialize the memory allocated by this method. The memory is owned by
5858 class MemoryBufferMem : public MemoryBuffer {
5959 std::string FileID;
6060 public:
61 MemoryBufferMem(const char *Start, const char *End, const char *FID)
61 MemoryBufferMem(const char *Start, const char *End, const char *FID,
62 bool Copy = false)
6263 : FileID(FID) {
63 init(Start, End);
64 if (!Copy)
65 init(Start, End);
66 else
67 initCopyOf(Start, End);
6468 }
6569
6670 virtual const char *getBufferIdentifier() const {
7579 const char *EndPtr,
7680 const char *BufferName) {
7781 return new MemoryBufferMem(StartPtr, EndPtr, BufferName);
82 }
83
84 /// getMemBufferCopy - Open the specified memory range as a MemoryBuffer,
85 /// copying the contents and taking ownership of it. This has no requirements
86 /// on EndPtr[0].
87 MemoryBuffer *MemoryBuffer::getMemBufferCopy(const char *StartPtr,
88 const char *EndPtr,
89 const char *BufferName) {
90 return new MemoryBufferMem(StartPtr, EndPtr, BufferName, true);
7891 }
7992
8093 /// getNewUninitMemBuffer - Allocate a new MemoryBuffer of the specified size