]> git.tdb.fi Git - libs/core.git/blobdiff - source/io/memory.cpp
Rewrite the hash functions to be more generic
[libs/core.git] / source / io / memory.cpp
index eaaaeb1829dfc5a59b481ca32e6e48170a78cc53..0b2d8f4c1b7f49ec7ccb93222d2bf48915abf3fd 100644 (file)
@@ -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<char *>(cd);
-       init(d, d+s, M_READ);
-}
-
-Memory::Memory(const char *b, const char *e)
-{
-       init(const_cast<char *>(b), const_cast<char *>(e), M_READ);
-}
-
-void Memory::init(char *b, char *e, Mode m)
 {
        begin = b;
        end = e;
@@ -47,17 +26,17 @@ void Memory::set_inherit(bool)
        throw logic_error("Memory::set_inherit");
 }
 
-unsigned Memory::do_write(const char *buf, unsigned size)
+size_t Memory::do_write(const char *buf, size_t size)
 {
        check_access(M_WRITE);
 
-       size = min<unsigned>(size, end-pos);
+       size = min<size_t>(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);
 
@@ -67,13 +46,13 @@ unsigned Memory::do_read(char *buf, unsigned size)
                return 0;
        }
 
-       size = min<unsigned>(size, end-pos);
+       size = min<size_t>(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);