summaryrefslogtreecommitdiff
path: root/qpid/cpp/src/qpid/RefCountedBuffer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qpid/cpp/src/qpid/RefCountedBuffer.cpp')
-rw-r--r--qpid/cpp/src/qpid/RefCountedBuffer.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/qpid/cpp/src/qpid/RefCountedBuffer.cpp b/qpid/cpp/src/qpid/RefCountedBuffer.cpp
index 40d620f7ad..a82e1a02ab 100644
--- a/qpid/cpp/src/qpid/RefCountedBuffer.cpp
+++ b/qpid/cpp/src/qpid/RefCountedBuffer.cpp
@@ -20,19 +20,22 @@
*/
#include "qpid/RefCountedBuffer.h"
+#include <stdlib.h>
#include <new>
namespace qpid {
void RefCountedBuffer::released() const {
this->~RefCountedBuffer();
- ::delete[] reinterpret_cast<const char*>(this);
+ ::free (reinterpret_cast<void *>(const_cast<RefCountedBuffer *>(this)));
}
BufferRef RefCountedBuffer::create(size_t n) {
- char* store=::new char[n+sizeof(RefCountedBuffer)];
+ void* store=::malloc (n + sizeof(RefCountedBuffer));
+ if (NULL == store)
+ throw std::bad_alloc();
new(store) RefCountedBuffer;
- char* start = store+sizeof(RefCountedBuffer);
+ char* start = reinterpret_cast<char *>(store) + sizeof(RefCountedBuffer);
return BufferRef(
boost::intrusive_ptr<RefCounted>(reinterpret_cast<RefCountedBuffer*>(store)),
start, start+n);