From 8c5ab54c9b9e4a815da83452d41527ac20915f3e Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Sun, 22 Jul 2012 21:25:36 +0200 Subject: [PATCH] Updated refcount.cpp to a newer coding convention. --- sortix/{ => include/sortix/kernel}/refcount.h | 32 ++++++------ sortix/refcount.cpp | 49 ++++++++++--------- 2 files changed, 41 insertions(+), 40 deletions(-) rename sortix/{ => include/sortix/kernel}/refcount.h (77%) diff --git a/sortix/refcount.h b/sortix/include/sortix/kernel/refcount.h similarity index 77% rename from sortix/refcount.h rename to sortix/include/sortix/kernel/refcount.h index 01e3622f..afa43fc4 100644 --- a/sortix/refcount.h +++ b/sortix/include/sortix/kernel/refcount.h @@ -1,6 +1,6 @@ /******************************************************************************* - COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2012. + Copyright(C) Jonas 'Sortie' Termansen 2012. This file is part of Sortix. @@ -25,24 +25,24 @@ #ifndef SORTIX_REFCOUNT_H #define SORTIX_REFCOUNT_H -namespace Sortix +namespace Sortix { + +class Refcounted { - class Refcounted - { - public: - Refcounted(); - ~Refcounted(); +public: + Refcounted(); + ~Refcounted(); - public: - void Refer(); - void Unref(); - inline size_t Refcount() const { return refcount; } +public: + void Refer(); + void Unref(); + inline size_t Refcount() const { return refcount; } - private: - size_t refcount; +private: + size_t refcount; - }; -} +}; + +} // namespace Sortix #endif - diff --git a/sortix/refcount.cpp b/sortix/refcount.cpp index 4cb32683..66133d0d 100644 --- a/sortix/refcount.cpp +++ b/sortix/refcount.cpp @@ -1,6 +1,6 @@ /******************************************************************************* - COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2012. + Copyright(C) Jonas 'Sortie' Termansen 2012. This file is part of Sortix. @@ -23,30 +23,31 @@ *******************************************************************************/ #include -#include "refcount.h" +#include -namespace Sortix +namespace Sortix { + +Refcounted::Refcounted() { - Refcounted::Refcounted() - { - refcount = 1; - } - - Refcounted::~Refcounted() - { - // It's OK to be deleted if our refcount is 1, it won't mess with any - // other owners that might need us. - ASSERT(refcount <= 1); - } - - void Refcounted::Refer() - { - refcount++; - } - - void Refcounted::Unref() - { - if ( !--refcount ) { delete this; } - } + refcount = 1; } +Refcounted::~Refcounted() +{ + // It's OK to be deleted if our refcount is 1, it won't mess with any + // other owners that might need us. + ASSERT(refcount <= 1); +} + +void Refcounted::Refer() +{ + refcount++; +} + +void Refcounted::Unref() +{ + if ( !--refcount ) + delete this; +} + +} // namespace Sortix