1
0
mirror of https://gitlab.xiph.org/xiph/icecast-common.git synced 2024-12-04 14:46:31 -05:00

Feature: Added igloo_ro_get_instance()

This commit is contained in:
Philipp Schafft 2019-09-14 12:05:52 +00:00
parent 92317644a5
commit eb9b0301a0
2 changed files with 28 additions and 0 deletions

View File

@ -312,6 +312,9 @@ const char * igloo_ro_get_name(igloo_ro_t self);
igloo_ro_t igloo_ro_get_associated(igloo_ro_t self);
igloo_error_t igloo_ro_set_associated(igloo_ro_t self, igloo_ro_t associated);
/* This gets the object's instance object. */
igloo_ro_t igloo_ro_get_instance(igloo_ro_t self);
/* Clone the given object returning a copy of it.
*
* This creates a copy of the passed object if possible.

View File

@ -314,6 +314,31 @@ igloo_error_t igloo_ro_set_associated(igloo_ro_t self, igloo_ro_t associated)
return igloo_ERROR_NONE;
}
igloo_ro_t igloo_ro_get_instance(igloo_ro_t self)
{
igloo_ro_base_t *base = igloo_RO__GETBASE(self);
igloo_ro_t ret;
if (!base)
return igloo_RO_NULL;
igloo_thread_mutex_lock(&(base->lock));
if (!base->refc) {
igloo_thread_mutex_unlock(&(base->lock));
return igloo_RO_NULL;
}
ret = base->instance;
if (!igloo_RO_IS_NULL(ret)) {
if (igloo_ro_ref(ret) != igloo_ERROR_NONE) {
igloo_thread_mutex_unlock(&(base->lock));
return igloo_RO_NULL;
}
}
igloo_thread_mutex_unlock(&(base->lock));
return ret;
}
igloo_ro_t igloo_ro_clone(igloo_ro_t self, igloo_ro_cf_t required, igloo_ro_cf_t allowed, const char *name, igloo_ro_t associated)
{
igloo_ro_base_t *base = igloo_RO__GETBASE(self);