mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
@ -27,6 +27,8 @@ sysprof_cplus_demangle (const char *name)
|
||||
char *real_name;
|
||||
char *ret;
|
||||
int status;
|
||||
guint i;
|
||||
guint j;
|
||||
|
||||
if (name == NULL)
|
||||
return NULL;
|
||||
@ -36,7 +38,30 @@ sysprof_cplus_demangle (const char *name)
|
||||
if (real_name == NULL)
|
||||
return NULL;
|
||||
|
||||
ret = g_strdup (real_name);
|
||||
/* We need to return a string that is guaranteed it can be freed with
|
||||
* g_free() rather than free(), so we might as well look for Legacy
|
||||
* Rust mangling like '$LT$' and '$GT$' while we're at it.
|
||||
*/
|
||||
|
||||
ret = (char *)g_malloc (strlen (real_name) + 1);
|
||||
|
||||
for (i = 0, j = 0; real_name[i]; i++)
|
||||
{
|
||||
if (real_name[i] == '$')
|
||||
{
|
||||
if (real_name[i+1] == 'L' && real_name[i+2] == 'T' && real_name[i+3] == '$')
|
||||
ret[j++] = '<', i += 3;
|
||||
else if (real_name[i+1] == 'G' && real_name[i+2] == 'T' && real_name[i+3] == '$')
|
||||
ret[j++] = '>', i += 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret[j++] = real_name[i];
|
||||
}
|
||||
}
|
||||
|
||||
ret[j] = 0;
|
||||
|
||||
free (real_name);
|
||||
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user