From: mental Date: Sat, 29 Apr 2006 18:39:19 +0000 (+0000) Subject: gc visibility rules X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=86d1438b2218a762b1c50895fbf91732d31f6452;p=inkscape.git gc visibility rules --- diff --git a/doc/refcounting.txt b/doc/refcounting.txt index 3cdb60584..a3cd02058 100644 --- a/doc/refcounting.txt +++ b/doc/refcounting.txt @@ -85,22 +85,31 @@ as it added and removed them. ANCHORED OBJECTS -The garbage collector cannot know about references from some types of objects: +The garbage collector can see pointers in: - * Gtk/gtkmm widgets + * global/static variables in the program - * SPObjects + * local variables/parameters - * other GObject-derived types + * objects derived from GC::Managed<> - * Glib data structures + * STL containers using GC::Alloc<> - * STL data structures that don't use GC::Alloc + * objects manually allocated with GC::SCANNED -To accomodate this, I've provided the GC::Anchored class from which -garbage-collector managed classes can be derived if they need to be -referenced from such places. As noted earlier, ref and unref functions are -GC::anchor() and GC::release(), respectively. +It cannot see pointers in: + + * global/static variables in shared libraries + + * objects not derived from GC::Managed<> + + * STL containers not using GC::Alloc<> + +Since a lot of important objects (e.g. gtkmm widgets or Glib collections) +fall into the latter category, I've provided the GC::Anchored class from +which garbage-collector managed classes can be derived if they may be +remembered exclusively by such places. As noted earlier, the associated +ref and unref functions are GC::anchor() and GC::release(), respectively. For most refcounted objects, a nonzero refcount means "this object is in use", and a zero refcount means "this object is no longer in use, you can diff --git a/src/debug/logger.cpp b/src/debug/logger.cpp index a3f6899ef..897a66c24 100644 --- a/src/debug/logger.cpp +++ b/src/debug/logger.cpp @@ -93,19 +93,28 @@ static void set_category_mask(bool * const mask, char const *filter) { while (*end) { while ( *end && *end != ',' ) { end++; } if ( start != end ) { - if (equal_range("CORE", start, end)) { - mask[Event::CORE] = true; - } else if (equal_range("XML", start, end)) { - mask[Event::XML] = true; - } else if (equal_range("SPOBJECT", start, end)) { - mask[Event::SPOBJECT] = true; - } else if (equal_range("DOCUMENT", start, end)) { - mask[Event::DOCUMENT] = true; - } else if (equal_range("REFCOUNT", start, end)) { - mask[Event::REFCOUNT] = true; - } else if (equal_range("EXTENSION", start, end)) { - mask[Event::EXTENSION] = true; - } else { + struct CategoryName { + char const *name, + Event::Category category + }; + static const category_names[] = { + { "CORE", Event::CORE }, + { "XML", Event::XML }, + { "SPOBJECT", Event::SPOBJECT }, + { "DOCUMENT", Event::DOCUMENT }, + { "REFCOUNT", Eevent::REFCOUNT }, + { "EXTENSION", Event::EXTENSION }, + { "OTHER", Event::OTHER }, + { NULL, Event::OTHER } + }; + CategoryName const *iter; + for ( iter = category_names ; iter.name ; iter++ ) { + if (equal_range(iter.name, start, end)) { + mask[iter.category] = true; + break; + } + } + if (!iter.name) { g_warning("Unknown debugging category %*s", end - start, start); } }