X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fio%2Fmemory.cpp;h=0b2d8f4c1b7f49ec7ccb93222d2bf48915abf3fd;hb=9b38e20254913629a0db40e8eb8e1c42e1728e41;hp=c5aee1e0536e040e72187172b2c084269596cce9;hpb=481b844ed7d180ffbf70223075f2fc1ffdb5b444;p=libs%2Fcore.git diff --git a/source/io/memory.cpp b/source/io/memory.cpp index c5aee1e..0b2d8f4 100644 --- a/source/io/memory.cpp +++ b/source/io/memory.cpp @@ -8,28 +8,7 @@ using namespace std; namespace Msp { namespace IO { -Memory::Memory(char *d, unsigned s, Mode m) -{ - init(d, d+s, m); -} - Memory::Memory(char *b, char *e, Mode m) -{ - init(b, e, m); -} - -Memory::Memory(const char *cd, unsigned s) -{ - char *d = const_cast(cd); - init(d, d+s, M_READ); -} - -Memory::Memory(const char *b, const char *e) -{ - init(const_cast(b), const_cast(e), M_READ); -} - -void Memory::init(char *b, char *e, Mode m) { begin = b; end = e; @@ -42,17 +21,22 @@ void Memory::set_block(bool) throw logic_error("Memory::set_block"); } -unsigned Memory::do_write(const char *buf, unsigned size) +void Memory::set_inherit(bool) +{ + throw logic_error("Memory::set_inherit"); +} + +size_t Memory::do_write(const char *buf, size_t size) { check_access(M_WRITE); - size = min(size, end-pos); + size = min(size, end-pos); memcpy(pos, buf, size); pos += size; return size; } -unsigned Memory::do_read(char *buf, unsigned size) +size_t Memory::do_read(char *buf, size_t size) { check_access(M_READ); @@ -62,13 +46,13 @@ unsigned Memory::do_read(char *buf, unsigned size) return 0; } - size = min(size, end-pos); + size = min(size, end-pos); memcpy(buf, pos, size); pos += size; return size; } -unsigned Memory::put(char c) +size_t Memory::put(char c) { check_access(M_WRITE);