mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-05-05 08:48:07 +02:00
_dbus_file_path_extract_elements_from_tail: don't misuse static variable
If we _dbus_verbose() from more than one thread at the same time, we don't want to get into trouble with static variables (and I don't think micro-optimizing this function is really worth it anyway). Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68610 Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
This commit is contained in:
parent
31edd76313
commit
cc28d8d910
1 changed files with 11 additions and 14 deletions
|
|
@ -332,25 +332,22 @@ _dbus_verbose_init (void)
|
|||
*/
|
||||
static char *_dbus_file_path_extract_elements_from_tail(const char *file,int level)
|
||||
{
|
||||
static int prefix = -1;
|
||||
int prefix = 0;
|
||||
char *p = (char *)file + strlen(file);
|
||||
int i = 0;
|
||||
|
||||
if (prefix == -1)
|
||||
for (;p >= file;p--)
|
||||
{
|
||||
char *p = (char *)file + strlen(file);
|
||||
int i = 0;
|
||||
prefix = 0;
|
||||
for (;p >= file;p--)
|
||||
if (DBUS_IS_DIR_SEPARATOR(*p))
|
||||
{
|
||||
if (DBUS_IS_DIR_SEPARATOR(*p))
|
||||
if (++i >= level)
|
||||
{
|
||||
if (++i >= level)
|
||||
{
|
||||
prefix = p-file+1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
prefix = p-file+1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (char *)file+prefix;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue