X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fgc-anchored.h;h=917930a966ca6e0ccdf26c3b8d48914c5e30ef85;hb=9ca3650bdc9735fc502059c1c6aa8c7f5038999b;hp=f9d609074e3a56d13640cc2638c1b9b141272655;hpb=6b15695578f07a3f72c4c9475c1a261a3021472a;p=inkscape.git diff --git a/src/gc-anchored.h b/src/gc-anchored.h index f9d609074..917930a96 100644 --- a/src/gc-anchored.h +++ b/src/gc-anchored.h @@ -3,8 +3,7 @@ * * Authors: * MenTaLguY - * - * Copyright (C) 2004 MenTaLguY + * * Copyright (C) 2004 MenTaLguY * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -40,7 +39,7 @@ namespace GC { * * Note that a cycle involving an anchored object (with nonzero refcount) * cannot be collected. To avoid this, don't increment refcounts for - * pointers between two garbage-collected objects. + * pointers between two GC-managed objects. * * @see Inkscape::GC::Managed * @see Inkscape::GC::Finalized @@ -50,22 +49,17 @@ namespace GC { class Anchored { public: - void anchor() const { - if (!_anchor) { - _anchor = _new_anchor(); - } - _anchor->refcount++; - } + void anchor() const; + void release() const; - void release() const { - if (!--_anchor->refcount) { - _free_anchor(_anchor); - _anchor = NULL; - } + // for debugging + unsigned _anchored_refcount() const { + return ( _anchor ? _anchor->refcount : 0 ); } protected: Anchored() : _anchor(NULL) { anchor(); } // initial refcount of one + virtual ~Anchored() {} private: struct Anchor : public Managed {