summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2019-01-23 04:28:54 +0000
committerMarc Jeanmougin <marcjeanmougin@free.fr>2019-01-24 17:08:27 +0000
commit7dd1ed2d4eb8f7042587d22c601e3b3ad40cdcc2 (patch)
treec936faa4f4f17374eacd937b926f7d474900bf7d /src
parentEvent: Switch all call sites from Util::ptr_shared to char const* or std::sha... (diff)
downloadinkscape-7dd1ed2d4eb8f7042587d22c601e3b3ad40cdcc2.tar.gz
inkscape-7dd1ed2d4eb8f7042587d22c601e3b3ad40cdcc2.zip
Demangle: Switch to std::shared_ptr.
Diffstat (limited to 'src')
-rw-r--r--src/debug/demangle.cpp17
-rw-r--r--src/debug/demangle.h5
-rw-r--r--src/gc-anchored.cpp2
-rw-r--r--src/object/sp-object.cpp2
4 files changed, 12 insertions, 14 deletions
diff --git a/src/debug/demangle.cpp b/src/debug/demangle.cpp
index 28b5d26d4..60e1f176d 100644
--- a/src/debug/demangle.cpp
+++ b/src/debug/demangle.cpp
@@ -13,9 +13,10 @@
#include <cstdio>
#include <cstring>
#include <map>
+#include <memory>
+#include <string>
#include "debug/demangle.h"
#include "util/format.h"
-#include "inkgc/gc-alloc.h"
namespace Inkscape {
@@ -46,23 +47,19 @@ struct string_less_than {
}
};
-typedef std::map<char const *, char const *, string_less_than> MangleCache;
+typedef std::map<char const *, std::shared_ptr<std::string>, string_less_than> MangleCache;
MangleCache mangle_cache;
}
-Util::ptr_shared demangle(char const *name) {
+std::shared_ptr<std::string> demangle(char const *name) {
MangleCache::iterator found=mangle_cache.find(name);
-
- char const *result;
if ( found != mangle_cache.end() ) {
- result = (*found).second;
- } else {
- result = demangle_helper(name);
- mangle_cache[name] = result;
+ return (*found).second;
}
- return Util::share_unsafe(result);
+ char const *result = demangle_helper(name);
+ return mangle_cache[name] = std::make_shared<std::string>(result);
}
}
diff --git a/src/debug/demangle.h b/src/debug/demangle.h
index 95042446f..ba747cd3a 100644
--- a/src/debug/demangle.h
+++ b/src/debug/demangle.h
@@ -13,13 +13,14 @@
#ifndef SEEN_INKSCAPE_DEBUG_DEMANGLE_H
#define SEEN_INKSCAPE_DEBUG_DEMANGLE_H
-#include "util/share.h"
+#include <memory>
+#include <string>
namespace Inkscape {
namespace Debug {
-Util::ptr_shared demangle(char const *name);
+std::shared_ptr<std::string> demangle(char const *name);
}
diff --git a/src/gc-anchored.cpp b/src/gc-anchored.cpp
index 517db2291..dc5a9e45c 100644
--- a/src/gc-anchored.cpp
+++ b/src/gc-anchored.cpp
@@ -33,7 +33,7 @@ public:
{
_addProperty("base", Util::format("%p", Core::base(const_cast<Anchored *>(object))).pointer());
_addProperty("pointer", Util::format("%p", object).pointer());
- _addProperty("class", Debug::demangle(typeid(*object).name()).pointer());
+ _addProperty("class", std::move(Debug::demangle(typeid(*object).name())));
_addProperty("new-refcount", object->_anchored_refcount() + bias);
}
};
diff --git a/src/object/sp-object.cpp b/src/object/sp-object.cpp
index 992c19970..5222fc5f2 100644
--- a/src/object/sp-object.cpp
+++ b/src/object/sp-object.cpp
@@ -206,7 +206,7 @@ public:
: BaseRefCountEvent(name)
{
_addProperty("object", Util::format("%p", object).pointer());
- _addProperty("class", Debug::demangle(g_type_name(G_TYPE_FROM_INSTANCE(object))).pointer());
+ _addProperty("class", std::move(Debug::demangle(g_type_name(G_TYPE_FROM_INSTANCE(object)))));
_addProperty("new-refcount", Util::format("%d", G_OBJECT(object)->ref_count + bias).pointer());
}
};