mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
Add new MemoryBuffer::getMemBufferCopy method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42815 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ec1f944230
commit
3daae2701b
@ -61,6 +61,12 @@ public:
|
||||
static MemoryBuffer *getMemBuffer(const char *StartPtr, const char *EndPtr,
|
||||
const char *BufferName = "");
|
||||
|
||||
/// getMemBufferCopy - Open the specified memory range as a MemoryBuffer,
|
||||
/// copying the contents and taking ownership of it. This has no requirements
|
||||
/// on EndPtr[0].
|
||||
static MemoryBuffer *getMemBufferCopy(const char *StartPtr,const char *EndPtr,
|
||||
const char *BufferName = "");
|
||||
|
||||
/// getNewMemBuffer - Allocate a new MemoryBuffer of the specified size that
|
||||
/// is completely initialized to zeros. Note that the caller should
|
||||
/// initialize the memory allocated by this method. The memory is owned by
|
||||
|
@ -59,9 +59,13 @@ namespace {
|
||||
class MemoryBufferMem : public MemoryBuffer {
|
||||
std::string FileID;
|
||||
public:
|
||||
MemoryBufferMem(const char *Start, const char *End, const char *FID)
|
||||
MemoryBufferMem(const char *Start, const char *End, const char *FID,
|
||||
bool Copy = false)
|
||||
: FileID(FID) {
|
||||
if (!Copy)
|
||||
init(Start, End);
|
||||
else
|
||||
initCopyOf(Start, End);
|
||||
}
|
||||
|
||||
virtual const char *getBufferIdentifier() const {
|
||||
@ -78,6 +82,15 @@ MemoryBuffer *MemoryBuffer::getMemBuffer(const char *StartPtr,
|
||||
return new MemoryBufferMem(StartPtr, EndPtr, BufferName);
|
||||
}
|
||||
|
||||
/// getMemBufferCopy - Open the specified memory range as a MemoryBuffer,
|
||||
/// copying the contents and taking ownership of it. This has no requirements
|
||||
/// on EndPtr[0].
|
||||
MemoryBuffer *MemoryBuffer::getMemBufferCopy(const char *StartPtr,
|
||||
const char *EndPtr,
|
||||
const char *BufferName) {
|
||||
return new MemoryBufferMem(StartPtr, EndPtr, BufferName, true);
|
||||
}
|
||||
|
||||
/// getNewUninitMemBuffer - Allocate a new MemoryBuffer of the specified size
|
||||
/// that is completely initialized to zeros. Note that the caller should
|
||||
/// initialize the memory allocated by this method. The memory is owned by
|
||||
|
Loading…
Reference in New Issue
Block a user