summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/RefCountedBuffer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/qpid/RefCountedBuffer.cpp')
-rw-r--r--cpp/src/qpid/RefCountedBuffer.cpp23
1 files changed, 7 insertions, 16 deletions
diff --git a/cpp/src/qpid/RefCountedBuffer.cpp b/cpp/src/qpid/RefCountedBuffer.cpp
index 72475f823e..a82e1a02ab 100644
--- a/cpp/src/qpid/RefCountedBuffer.cpp
+++ b/cpp/src/qpid/RefCountedBuffer.cpp
@@ -20,33 +20,24 @@
*/
#include "qpid/RefCountedBuffer.h"
+#include <stdlib.h>
#include <new>
-#include <boost/cstdint.hpp>
namespace qpid {
void RefCountedBuffer::released() const {
this->~RefCountedBuffer();
- uintptr_t binStoreRaw = reinterpret_cast<uintptr_t>(this);
- binStoreRaw -= alignPad;
- ::delete[] reinterpret_cast<const char*>(binStoreRaw);
+ ::free (reinterpret_cast<void *>(const_cast<RefCountedBuffer *>(this)));
}
BufferRef RefCountedBuffer::create(size_t n) {
- char * storeRaw = ::new char[n + sizeof(RefCountedBuffer) +
- refCountedBufferStructAlign];
- uintptr_t binStoreRaw = reinterpret_cast<uintptr_t>(storeRaw);
- uintptr_t binStore = (binStoreRaw +
- refCountedBufferStructAlign-1) & ~(refCountedBufferStructAlign-1);
- char * store = reinterpret_cast<char*>(binStore);
-
+ void* store=::malloc (n + sizeof(RefCountedBuffer));
+ if (NULL == store)
+ throw std::bad_alloc();
new(store) RefCountedBuffer;
-
- reinterpret_cast<RefCountedBuffer*>((void *)store)->alignPad = binStore - binStoreRaw;
-
- char* start = store+sizeof(RefCountedBuffer);
+ char* start = reinterpret_cast<char *>(store) + sizeof(RefCountedBuffer);
return BufferRef(
- boost::intrusive_ptr<RefCounted>(reinterpret_cast<RefCountedBuffer*>((void *)store)),
+ boost::intrusive_ptr<RefCounted>(reinterpret_cast<RefCountedBuffer*>(store)),
start, start+n);
}