Commit c139e40a authored by David COME's avatar David COME
Browse files

removed auto_ptr<char> for payload to a dedicated structure

Indeed, there was a clash into auto_ptr destructor (which does a delete) and the allocation which was done using new[]
parent 17a75f10
......@@ -27,13 +27,42 @@
#include "castor/tape/tapeserver/daemon/Exception.hpp"
#include <memory>
class MemBlock {
class Payload
MemBlock(const int id, const size_t capacity) throw(MemException) : m_memoryBlockId(id), m_payload(new (std::nothrow) char[capacity]), m_payload_capacity(capacity) {
if(m_payload.get()==NULL) {
Payload(size_t capacity):
m_payload(new (std::nothrow) char[capacity]),m_capacity(capacity),m_size(0) {
if(NULL == m_payload) {
throw MemException("Failed to allocate memory for a new MemBlock!");
delete[] m_payload;
size_t size() const {
return m_size;
size_t capacity() const {
return m_capacity;
//TODO interface TBD
char* get(){
return m_payload;
char* m_payload;
size_t m_capacity;
size_t m_size;
class MemBlock {
MemBlock(const int id, const size_t capacity) throw(MemException) :
......@@ -45,13 +74,10 @@ public:
int m_memoryBlockId;
Payload m_payload;
int m_fileid;
int m_fileBlock;
int m_fSeq;
int m_tapeFileBlock;
std::auto_ptr<char> m_payload;
size_t m_payload_capacity;
size_t m_payload_size;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment