MCPcopy Create free account
hub / github.com/arvidn/libtorrent / demangle

Function demangle

src/assert.cpp:72–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70
71namespace libtorrent {
72std::string demangle(char const* name)
73{
74// in case this string comes
75 // this is needed on linux
76 char const* start = std::strchr(name, '(');
77 if (start != nullptr)
78 {
79 ++start;
80 }
81 else
82 {
83 // this is needed on macos x
84 start = strstr(name, "0x");
85 if (start != nullptr)
86 {
87 start = std::strchr(start, ' ');
88 if (start != nullptr) ++start;
89 else start = name;
90 }
91 else start = name;
92 }
93
94 char const* end = std::strchr(start, '+');
95 if (end) while (*(end-1) == ' ') --end;
96
97 std::string in;
98 if (end == nullptr) in.assign(start);
99 else in.assign(start, end);
100
101 size_t len;
102 int status;
103 char* unmangled = ::abi::__cxa_demangle(in.c_str(), nullptr, &len, &status);
104 if (unmangled == nullptr) return in;
105 std::string ret(unmangled);
106 ::free(unmangled);
107 return ret;
108}
109}
110#elif defined _WIN32 && !defined TORRENT_WINRT
111

Callers 2

print_backtraceFunction · 0.85
log_handler_allocatorsFunction · 0.85

Calls 1

assignMethod · 0.45

Tested by

no test coverage detected