From ec9d3c889f5ebb228bd185eb954103e52f38c2b2 Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Fri, 13 Feb 2009 08:24:55 +0000 Subject: [PATCH] Switch from new[] + delete[] to malloc + free since llvm does not catch C++ exceptions. llvm-svn: 64448 --- lib/Support/MemoryBuffer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Support/MemoryBuffer.cpp b/lib/Support/MemoryBuffer.cpp index 0e60eab301e..a4963d92fb6 100644 --- a/lib/Support/MemoryBuffer.cpp +++ b/lib/Support/MemoryBuffer.cpp @@ -38,7 +38,7 @@ using namespace llvm; MemoryBuffer::~MemoryBuffer() { if (MustDeleteBuffer) - delete [] BufferStart; + free((void*)BufferStart); } /// initCopyOf - Initialize this source buffer with a copy of the specified @@ -46,7 +46,7 @@ MemoryBuffer::~MemoryBuffer() { /// successfully. void MemoryBuffer::initCopyOf(const char *BufStart, const char *BufEnd) { size_t Size = BufEnd-BufStart; - BufferStart = new char[Size+1]; + BufferStart = (char *)malloc((Size+1) * sizeof(char)); BufferEnd = BufferStart+Size; memcpy(const_cast(BufferStart), BufStart, Size); *const_cast(BufferEnd) = 0; // Null terminate buffer. @@ -108,7 +108,7 @@ MemoryBuffer *MemoryBuffer::getMemBufferCopy(const char *StartPtr, /// the MemoryBuffer object. MemoryBuffer *MemoryBuffer::getNewUninitMemBuffer(size_t Size, const char *BufferName) { - char *Buf = new char[Size+1]; + char *Buf = (char *)malloc((Size+1) * sizeof(char)); if (!Buf) return 0; Buf[Size] = 0; MemoryBufferMem *SB = new MemoryBufferMem(Buf, Buf+Size, BufferName);