From 7dd1ed2d4eb8f7042587d22c601e3b3ad40cdcc2 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Wed, 23 Jan 2019 05:28:54 +0100 Subject: Demangle: Switch to std::shared_ptr. --- src/debug/demangle.cpp | 17 +++++++---------- src/debug/demangle.h | 5 +++-- 2 files changed, 10 insertions(+), 12 deletions(-) (limited to 'src/debug') 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 #include #include +#include +#include #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 MangleCache; +typedef std::map, string_less_than> MangleCache; MangleCache mangle_cache; } -Util::ptr_shared demangle(char const *name) { +std::shared_ptr 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(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 +#include namespace Inkscape { namespace Debug { -Util::ptr_shared demangle(char const *name); +std::shared_ptr demangle(char const *name); } -- cgit v1.2.3