X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fmemory.cpp;h=6ea130b54ae134478ab40851f4c49cf1d68ad439;hp=80dde272625a25ed2a7b644460e7f576c853f7aa;hb=b97d4e9f86e90254ab9edef7ee62a910f6333c78;hpb=73a21b6f495e16707ede460a2c9d8f1474bb4d93 diff --git a/source/memory.cpp b/source/memory.cpp index 80dde27..6ea130b 100644 --- a/source/memory.cpp +++ b/source/memory.cpp @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of libmspio -Copyright © 2009 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #include #include #include "except.h" @@ -44,6 +37,30 @@ void Memory::init(char *b, char *e, Mode m) mode = m; } +unsigned Memory::do_write(const char *buf, unsigned size) +{ + check_mode(M_WRITE); + + size = min(size, end-pos); + memcpy(pos, buf, size); + pos += size; + return size; +} + +unsigned Memory::do_read(char *buf, unsigned size) +{ + if(pos==end) + { + eof_flag = true; + return 0; + } + + size = min(size, end-pos); + memcpy(buf, pos, size); + pos += size; + return size; +} + unsigned Memory::put(char c) { check_mode(M_WRITE); @@ -95,30 +112,6 @@ Handle Memory::get_event_handle() throw Exception("Memory doesn't support events"); } -unsigned Memory::do_write(const char *buf, unsigned size) -{ - check_mode(M_WRITE); - - size = min(size, end-pos); - memcpy(pos, buf, size); - pos += size; - return size; -} - -unsigned Memory::do_read(char *buf, unsigned size) -{ - if(pos==end) - { - eof_flag = true; - return 0; - } - - size = min(size, end-pos); - memcpy(buf, pos, size); - pos += size; - return size; -} - void Memory::check_mode(Mode m) const { if(m==M_WRITE)