diff options
| author | Jan Lingscheid <jan.linscheid@auticon.de> | 2017-10-18 14:03:34 +0000 |
|---|---|---|
| committer | Jan Lingscheid <jan.linscheid@auticon.de> | 2017-10-18 14:03:34 +0000 |
| commit | 41b862f1c4eaea48bdd0d546e2bb31907f15857b (patch) | |
| tree | e667c91439f0f04aa1f2cec1d3eafddf80bc4ecc /src/debug | |
| parent | Replace boost::shared_ptr (diff) | |
| download | inkscape-41b862f1c4eaea48bdd0d546e2bb31907f15857b.tar.gz inkscape-41b862f1c4eaea48bdd0d546e2bb31907f15857b.zip | |
Refactor Util::ptr_shared
Util::ptr_shared<T> was only used in its <char> specialization, so it is now refactored into a
non-template class. Using it with arbitary classes was dangerous anyway.
Diffstat (limited to 'src/debug')
| -rw-r--r-- | src/debug/demangle.cpp | 2 | ||||
| -rw-r--r-- | src/debug/demangle.h | 2 | ||||
| -rw-r--r-- | src/debug/event.h | 12 | ||||
| -rw-r--r-- | src/debug/gc-heap.h | 2 | ||||
| -rw-r--r-- | src/debug/heap.h | 2 | ||||
| -rw-r--r-- | src/debug/logger.cpp | 8 | ||||
| -rw-r--r-- | src/debug/simple-event.h | 18 | ||||
| -rw-r--r-- | src/debug/sysv-heap.h | 2 | ||||
| -rw-r--r-- | src/debug/timestamp.cpp | 4 | ||||
| -rw-r--r-- | src/debug/timestamp.h | 2 |
10 files changed, 27 insertions, 27 deletions
diff --git a/src/debug/demangle.cpp b/src/debug/demangle.cpp index 1d94f0eb9..04fe80d9b 100644 --- a/src/debug/demangle.cpp +++ b/src/debug/demangle.cpp @@ -50,7 +50,7 @@ MangleCache mangle_cache; } -Util::ptr_shared<char> demangle(char const *name) { +Util::ptr_shared demangle(char const *name) { MangleCache::iterator found=mangle_cache.find(name); char const *result; diff --git a/src/debug/demangle.h b/src/debug/demangle.h index 7505d9550..c5e160caa 100644 --- a/src/debug/demangle.h +++ b/src/debug/demangle.h @@ -18,7 +18,7 @@ namespace Inkscape { namespace Debug { -Util::ptr_shared<char> demangle(char const *name); +Util::ptr_shared demangle(char const *name); } diff --git a/src/debug/event.h b/src/debug/event.h index 1cdd4f7e2..2d3751ff5 100644 --- a/src/debug/event.h +++ b/src/debug/event.h @@ -40,23 +40,23 @@ public: struct PropertyPair { public: PropertyPair() {} - PropertyPair(Util::ptr_shared<char> n, Util::ptr_shared<char> v) + PropertyPair(Util::ptr_shared n, Util::ptr_shared v) : name(n), value(v) {} - PropertyPair(char const *n, Util::ptr_shared<char> v) + PropertyPair(char const *n, Util::ptr_shared v) : name(Util::share_string(n)), value(v) {} - PropertyPair(Util::ptr_shared<char> n, char const *v) + PropertyPair(Util::ptr_shared n, char const *v) : name(n), value(Util::share_string(v)) {} PropertyPair(char const *n, char const *v) : name(Util::share_string(n)), value(Util::share_string(v)) {} - Util::ptr_shared<char> name; - Util::ptr_shared<char> value; + Util::ptr_shared name; + Util::ptr_shared value; }; static Category category() { return OTHER; } - virtual Util::ptr_shared<char> name() const=0; + virtual Util::ptr_shared name() const=0; virtual unsigned propertyCount() const=0; virtual PropertyPair property(unsigned property) const=0; diff --git a/src/debug/gc-heap.h b/src/debug/gc-heap.h index d120ddba9..0daf39487 100644 --- a/src/debug/gc-heap.h +++ b/src/debug/gc-heap.h @@ -23,7 +23,7 @@ public: int features() const { return SIZE_AVAILABLE | USED_AVAILABLE | GARBAGE_COLLECTED; } - Util::ptr_shared<char> name() const { + Util::ptr_shared name() const { return Util::share_static_string("libgc"); } Heap::Stats stats() const { diff --git a/src/debug/heap.h b/src/debug/heap.h index e1e01f022..d7d39efb9 100644 --- a/src/debug/heap.h +++ b/src/debug/heap.h @@ -36,7 +36,7 @@ public: virtual int features() const=0; - virtual Util::ptr_shared<char> name() const=0; + virtual Util::ptr_shared name() const=0; virtual Stats stats() const=0; virtual void force_collect()=0; }; diff --git a/src/debug/logger.cpp b/src/debug/logger.cpp index 2eb81a0ba..d422b8e72 100644 --- a/src/debug/logger.cpp +++ b/src/debug/logger.cpp @@ -26,7 +26,7 @@ bool Logger::_category_mask[Event::N_CATEGORIES]; namespace { -static void write_escaped_value(std::ostream &os, Util::ptr_shared<char> value) { +static void write_escaped_value(std::ostream &os, Util::ptr_shared value) { for ( char const *current=value ; *current ; ++current ) { switch (*current) { case '&': @@ -58,7 +58,7 @@ static void write_indent(std::ostream &os, unsigned depth) { static std::ofstream log_stream; static bool empty_tag=false; -typedef std::vector<Util::ptr_shared<char>, GC::Alloc<Util::ptr_shared<char>, GC::MANUAL> > TagStack; +typedef std::vector<Util::ptr_shared, GC::Alloc<Util::ptr_shared, GC::MANUAL> > TagStack; static TagStack &tag_stack() { static TagStack stack; return stack; @@ -158,7 +158,7 @@ void Logger::init() { } void Logger::_start(Event const &event) { - Util::ptr_shared<char> name=event.name(); + Util::ptr_shared name=event.name(); if (empty_tag) { log_stream << ">\n"; @@ -185,7 +185,7 @@ void Logger::_start(Event const &event) { } void Logger::_skip() { - tag_stack().push_back(Util::ptr_shared<char>()); + tag_stack().push_back(Util::ptr_shared()); } void Logger::_finish() { diff --git a/src/debug/simple-event.h b/src/debug/simple-event.h index 03ce5d326..076b9b4b5 100644 --- a/src/debug/simple-event.h +++ b/src/debug/simple-event.h @@ -26,7 +26,7 @@ namespace Debug { template <Event::Category C=Event::OTHER> class SimpleEvent : public Event { public: - explicit SimpleEvent(Util::ptr_shared<char> name) : _name(name) {} + explicit SimpleEvent(Util::ptr_shared name) : _name(name) {} explicit SimpleEvent(char const *name) : _name(Util::share_string(name)) {} // default copy @@ -34,7 +34,7 @@ public: static Category category() { return C; } - Util::ptr_shared<char> name() const { return _name; } + Util::ptr_shared name() const { return _name; } unsigned propertyCount() const { return _properties.size(); } PropertyPair property(unsigned property) const { return _properties[property]; @@ -43,21 +43,21 @@ public: void generateChildEvents() const {} protected: - void _addProperty(Util::ptr_shared<char> name, - Util::ptr_shared<char> value) + void _addProperty(Util::ptr_shared name, + Util::ptr_shared value) { _properties.push_back(PropertyPair(name, value)); } - void _addProperty(Util::ptr_shared<char> name, char const *value) { + void _addProperty(Util::ptr_shared name, char const *value) { _addProperty(name, Util::share_string(value)); } - void _addProperty(char const *name, Util::ptr_shared<char> value) { + void _addProperty(char const *name, Util::ptr_shared value) { _addProperty(Util::share_string(name), value); } void _addProperty(char const *name, char const *value) { _addProperty(Util::share_string(name), Util::share_string(value)); } - void _addProperty(Util::ptr_shared<char> name, long value) { + void _addProperty(Util::ptr_shared name, long value) { _addFormattedProperty(name, "%ld", value); } void _addProperty(char const *name, long value) { @@ -65,10 +65,10 @@ protected: } private: - Util::ptr_shared<char> _name; + Util::ptr_shared _name; std::vector<PropertyPair, GC::Alloc<PropertyPair, GC::AUTO> > _properties; - void _addFormattedProperty(Util::ptr_shared<char> name, char const *format, ...) + void _addFormattedProperty(Util::ptr_shared name, char const *format, ...) { va_list args; va_start(args, format); diff --git a/src/debug/sysv-heap.h b/src/debug/sysv-heap.h index ba8f5db83..4bde77cd8 100644 --- a/src/debug/sysv-heap.h +++ b/src/debug/sysv-heap.h @@ -23,7 +23,7 @@ public: int features() const; - Util::ptr_shared<char> name() const { + Util::ptr_shared name() const { return Util::share_static_string("standard malloc()"); } Stats stats() const; diff --git a/src/debug/timestamp.cpp b/src/debug/timestamp.cpp index 6de03a463..cdd47e881 100644 --- a/src/debug/timestamp.cpp +++ b/src/debug/timestamp.cpp @@ -19,8 +19,8 @@ namespace Inkscape { namespace Debug { -Util::ptr_shared<char> timestamp() { - Util::ptr_shared<char> result; +Util::ptr_shared timestamp() { + Util::ptr_shared result; GTimeVal timestamp; g_get_current_time(×tamp); gchar *value = g_strdup_printf( "%d.%06d", static_cast<gint>(timestamp.tv_sec), static_cast<gint>(timestamp.tv_usec) ); diff --git a/src/debug/timestamp.h b/src/debug/timestamp.h index 336ed5d0f..c145ffbc9 100644 --- a/src/debug/timestamp.h +++ b/src/debug/timestamp.h @@ -18,7 +18,7 @@ namespace Inkscape { namespace Debug { -Util::ptr_shared<char> timestamp(); +Util::ptr_shared timestamp(); } |
