Subversion Repositories Filer-Free

Rev

Rev 11 | Blame | Compare with Previous | Last modification | View Log | RSS feed

// This file is part of the free Filer module for RISC OS.
// Copyright © 2007 Graham Shaw.
// Redistribution and modification are permitted under the terms of the
// GNU General Public License (version 2 or any later version).

#include <new>

#include "auto_buffer.h"

auto_buffer::auto_buffer(size_type size):
        _buffer(new(std::nothrow) char[size])
{}

auto_buffer& auto_buffer::operator=(auto_buffer& buffer)
{
        if (buffer._buffer!=_buffer)
        {
                delete[] _buffer;
                _buffer=buffer._buffer;
                buffer._buffer=0;
        }
        return *this;
}

auto_buffer& auto_buffer::operator=(auto_buffer_ref ref)
{
        if (ref._buffer!=_buffer)
        {
                delete[] _buffer;
                _buffer=ref._buffer;
                ref._buffer=0;
        }
        return *this;
}

auto_buffer::operator auto_buffer_ref()
{
        element_type* buffer=_buffer;
        _buffer=0;
        return auto_buffer_ref(buffer);
}