Subversion Repositories Filer-Free

Rev

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

Rev Author Line No. Line
11 gdshaw@RISCPKG.ORG 1
// This file is part of the free Filer module for RISC OS.
2
// Copyright  2007 Graham Shaw.
3
// Redistribution and modification are permitted under the terms of the
4
// GNU General Public License (version 2 or any later version).
5
 
64 gdshaw@RISCPKG.ORG 6
#include <new>
7
 
11 gdshaw@RISCPKG.ORG 8
#include "auto_buffer.h"
9
 
10
auto_buffer::auto_buffer(size_type size):
64 gdshaw@RISCPKG.ORG 11
        _buffer(new(std::nothrow) char[size])
11 gdshaw@RISCPKG.ORG 12
{}
13
 
14
auto_buffer& auto_buffer::operator=(auto_buffer& buffer)
15
{
16
        if (buffer._buffer!=_buffer)
17
        {
18
                delete[] _buffer;
19
                _buffer=buffer._buffer;
20
                buffer._buffer=0;
21
        }
22
        return *this;
23
}
24
 
25
auto_buffer& auto_buffer::operator=(auto_buffer_ref ref)
26
{
27
        if (ref._buffer!=_buffer)
28
        {
29
                delete[] _buffer;
30
                _buffer=ref._buffer;
31
                ref._buffer=0;
32
        }
33
        return *this;
34
}
35
 
36
auto_buffer::operator auto_buffer_ref()
37
{
38
        element_type* buffer=_buffer;
39
        _buffer=0;
40
        return auto_buffer_ref(buffer);
41
}