/* * Copyright (c) 2002, Stefan Farfeleder * $Id: objhandle.cc,v 1.2 2002/09/19 10:42:02 stefan Exp $ */ #include #include "object_s.h" #include "objhandle.h" using namespace JFK::server; object* objhandle::gethandle(object* obj) { if (obj != NULL) obj->refcnt++; return obj; } void objhandle::freehandle(object* obj) { if (obj != NULL) { assert(obj->refcnt > 0); if (--obj->refcnt == 0) delete obj; } } objhandle& objhandle::operator=(const objhandle& oh) { if (&oh != this) { freehandle(o); o = gethandle(oh.o); } return *this; } void objhandle::assign(const objhandle oh) { /* save old refcnt!!! */ int tmp = o->refcnt; o->assign(oh.o); o->refcnt = tmp; }