X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fmemory.cpp;fp=source%2Fmemory.cpp;h=6ea130b54ae134478ab40851f4c49cf1d68ad439;hp=13a6606b8e9a6623dd3ae70ec3e574abfaab4574;hb=b97d4e9f86e90254ab9edef7ee62a910f6333c78;hpb=49c1f3c3ffdf318579a809f3f800442c0c76c818 diff --git a/source/memory.cpp b/source/memory.cpp index 13a6606..6ea130b 100644 --- a/source/memory.cpp +++ b/source/memory.cpp @@ -37,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); @@ -88,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)