mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2025-02-02 15:07:36 -05:00
Update: As of now we have no weak refs, so not store mount identifier in a tree
This commit is contained in:
parent
cf6fad00bd
commit
6c1233402d
@ -26,8 +26,6 @@ struct mount_identifier_tag {
|
|||||||
|
|
||||||
REFOBJECT_DEFINE_TYPE(mount_identifier_t);
|
REFOBJECT_DEFINE_TYPE(mount_identifier_t);
|
||||||
|
|
||||||
static avl_tree *mount_identifier_list;
|
|
||||||
|
|
||||||
static int mount_identifier_compare(void *compare_arg, void *a, void *b)
|
static int mount_identifier_compare(void *compare_arg, void *a, void *b)
|
||||||
{
|
{
|
||||||
const char *id_a, *id_b;
|
const char *id_a, *id_b;
|
||||||
@ -44,19 +42,16 @@ static int mount_identifier_compare(void *compare_arg, void *a, void *b)
|
|||||||
|
|
||||||
void navigation_initialize(void)
|
void navigation_initialize(void)
|
||||||
{
|
{
|
||||||
mount_identifier_list = avl_tree_new(mount_identifier_compare, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void navigation_shutdown(void)
|
void navigation_shutdown(void)
|
||||||
{
|
{
|
||||||
avl_tree_free(mount_identifier_list, (avl_free_key_fun_type)refobject_unref);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
mount_identifier_t * mount_identifier_new(const char *mount)
|
mount_identifier_t * mount_identifier_new(const char *mount)
|
||||||
{
|
{
|
||||||
mount_identifier_t *n;
|
mount_identifier_t *n;
|
||||||
void *result;
|
|
||||||
|
|
||||||
if (!mount)
|
if (!mount)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -65,16 +60,5 @@ mount_identifier_t * mount_identifier_new(const char *mount)
|
|||||||
if (!n)
|
if (!n)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
avl_tree_wlock(mount_identifier_list);
|
|
||||||
if (avl_get_by_key(mount_identifier_list, n, &result) == 0) {
|
|
||||||
refobject_unref(n);
|
|
||||||
n = result;
|
|
||||||
refobject_ref(n);
|
|
||||||
} else {
|
|
||||||
refobject_ref(n);
|
|
||||||
avl_insert(mount_identifier_list, n);
|
|
||||||
}
|
|
||||||
avl_tree_unlock(mount_identifier_list);
|
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user