From f40de21e5666be6fa456fedc60584bd672d12c44 Mon Sep 17 00:00:00 2001 From: Pixel Date: Tue, 22 Jan 2013 08:29:55 -0800 Subject: Removing some more cruft. --- includes/Handle.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'includes/Handle.h') diff --git a/includes/Handle.h b/includes/Handle.h index e12fab7..f501ab1 100644 --- a/includes/Handle.h +++ b/includes/Handle.h @@ -59,7 +59,7 @@ class Handle { ssize_t forceWrite(const String & str) { return forceWrite(str.to_charp(), str.strlen()); } uint8_t readU8() { uint8_t r; read(&r, 1); return r; } protected: - Handle() : m_refCount(0) { } + Handle() { } private: void addRef() { Atomic::Increment(&m_refCount); } void delRef() { @@ -73,7 +73,7 @@ class Handle { template friend class IO; - volatile int m_refCount; + volatile int m_refCount = 0; Handle(const Handle &) = delete; Handle & operator=(const Handle &) = delete; @@ -87,17 +87,17 @@ class HPrinter : public Handle { virtual bool canWrite() { return true; } virtual const char * getName() { return "HPrinter"; } virtual ssize_t write(const void * buf, size_t count) throw (GeneralException) { - Printer::print("%s", (const char *) buf); + Printer::print("%*s", (int) count, (const char *) buf); return count; } }; class IOBase { - protected: - IOBase() : m_h(NULL) { } + private: + IOBase() { } ~IOBase() { if (m_h) m_h->delRef(); } void setHandle(Handle * h) { m_h = h; if (m_h) m_h->addRef(); } - Handle * m_h; + Handle * m_h = NULL; template friend class IO; }; @@ -108,8 +108,11 @@ class IO : public IOBase { IO() { } IO(T * h) { setHandle(h); } IO(const IO & io) { if (io.m_h) setHandle(io.m_h); } + IO(IO && io) { m_h = io.m_h; io.m_h = NULL; } template IO(const IO & io) { if (io.m_h) setHandle(io.m_h); } + template + IO(IO && io) { m_h = io.m_h; io.m_h = NULL; } template bool isA() { return !!dynamic_cast(m_h); } template -- cgit v1.2.3