mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2024-12-04 14:46:30 -05:00
Update: Replaced reportxml_new() and reportxml_database_new()
This commit is contained in:
parent
fea817da2d
commit
a242f0f77b
@ -232,7 +232,7 @@ void config_init_configuration(ice_config_t *configuration)
|
||||
{
|
||||
memset(configuration, 0, sizeof(ice_config_t));
|
||||
_set_defaults(configuration);
|
||||
configuration->reportxml_db = reportxml_database_new();
|
||||
configuration->reportxml_db = refobject_new(reportxml_database_t);
|
||||
}
|
||||
|
||||
static inline void __read_int(xmlDocPtr doc, xmlNodePtr node, int *val, const char *warning)
|
||||
|
@ -661,7 +661,7 @@ reportxml_t *client_get_reportxml(const char *state_definition, const char *stat
|
||||
if (!report) {
|
||||
reportxml_node_t *rootnode, *incidentnode, *statenode;
|
||||
|
||||
report = reportxml_new();
|
||||
report = refobject_new(reportxml_t);
|
||||
rootnode = reportxml_get_root_node(report);
|
||||
incidentnode = reportxml_node_new(REPORTXML_NODE_TYPE_INCIDENT, NULL, NULL, NULL);
|
||||
statenode = reportxml_node_new(REPORTXML_NODE_TYPE_STATE, NULL, state_definition, state_akindof);
|
||||
|
@ -236,8 +236,22 @@ static void __report_free(refobject_t self, void **userdata)
|
||||
refobject_unref(report->root);
|
||||
}
|
||||
|
||||
static int __report_new(refobject_t self, const refobject_type_t *type, va_list ap)
|
||||
{
|
||||
reportxml_t *ret = REFOBJECT_TO_TYPE(self, reportxml_t*);
|
||||
reportxml_node_t *root = reportxml_node_new(REPORTXML_NODE_TYPE_REPORT, NULL, NULL, NULL);
|
||||
|
||||
if (!root)
|
||||
return -1;
|
||||
|
||||
ret->root = root;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
REFOBJECT_DEFINE_TYPE(reportxml_t,
|
||||
REFOBJECT_DEFINE_TYPE_FREE(__report_free)
|
||||
REFOBJECT_DEFINE_TYPE_FREE(__report_free),
|
||||
REFOBJECT_DEFINE_TYPE_NEW(__report_new)
|
||||
);
|
||||
|
||||
static reportxml_t * reportxml_new_with_root(reportxml_node_t *root)
|
||||
@ -255,20 +269,7 @@ static reportxml_t * reportxml_new_with_root(reportxml_node_t *root)
|
||||
|
||||
reportxml_t * reportxml_new(void)
|
||||
{
|
||||
reportxml_node_t *root = reportxml_node_new(REPORTXML_NODE_TYPE_REPORT, NULL, NULL, NULL);
|
||||
reportxml_t *ret;
|
||||
|
||||
if (!root)
|
||||
return NULL;
|
||||
|
||||
ret = reportxml_new_with_root(root);
|
||||
|
||||
if (!ret) {
|
||||
refobject_unref(root);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return refobject_new(reportxml_t);
|
||||
}
|
||||
|
||||
reportxml_node_t * reportxml_get_root_node(reportxml_t *report)
|
||||
@ -983,26 +984,27 @@ static int __compare_definitions(void *arg, void *a, void *b)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int __database_new(refobject_t self, const refobject_type_t *type, va_list ap)
|
||||
{
|
||||
reportxml_database_t *ret = REFOBJECT_TO_TYPE(self, reportxml_database_t*);
|
||||
|
||||
thread_mutex_create(&(ret->lock));
|
||||
|
||||
ret->definitions = avl_tree_new(__compare_definitions, NULL);
|
||||
if (!ret->definitions)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
REFOBJECT_DEFINE_TYPE(reportxml_database_t,
|
||||
REFOBJECT_DEFINE_TYPE_FREE(__database_free)
|
||||
REFOBJECT_DEFINE_TYPE_FREE(__database_free),
|
||||
REFOBJECT_DEFINE_TYPE_NEW(__database_new)
|
||||
);
|
||||
|
||||
reportxml_database_t * reportxml_database_new(void)
|
||||
{
|
||||
reportxml_database_t *ret = refobject_new__new(reportxml_database_t, NULL, NULL, NULL);
|
||||
|
||||
if (!ret)
|
||||
return NULL;
|
||||
|
||||
ret->definitions = avl_tree_new(__compare_definitions, NULL);
|
||||
if (!ret->definitions) {
|
||||
refobject_unref(ret);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
thread_mutex_create(&(ret->lock));
|
||||
|
||||
return ret;
|
||||
return refobject_new(reportxml_database_t);
|
||||
}
|
||||
|
||||
int reportxml_database_add_report(reportxml_database_t *db, reportxml_t *report)
|
||||
@ -1305,7 +1307,7 @@ reportxml_t * reportxml_database_build_report(reportxml_database_t *db
|
||||
/* Empty definition? Not exactly an exciting report... */
|
||||
ICECAST_LOG_WARN("Empty definition for \"%H\". Returning empty report. This is likely an error.", id);
|
||||
refobject_unref(definition);
|
||||
return reportxml_new();
|
||||
return refobject_new(reportxml_t);
|
||||
}
|
||||
|
||||
if (type == REPORTXML_NODE_TYPE__ERROR) {
|
||||
@ -1333,7 +1335,7 @@ reportxml_t * reportxml_database_build_report(reportxml_database_t *db
|
||||
break;
|
||||
}
|
||||
|
||||
ret = reportxml_new();
|
||||
ret = refobject_new(reportxml_t);
|
||||
if (!ret) {
|
||||
refobject_unref(definition);
|
||||
ICECAST_LOG_ERROR("Can not allocate new report. BAD.");
|
||||
|
@ -68,7 +68,9 @@ REFOBJECT_FORWARD_TYPE(reportxml_database_t);
|
||||
/* ---[ Document level ]--- */
|
||||
/* The document object is NOT thread safe. */
|
||||
|
||||
/* This creates a new, empty report XML document */
|
||||
/* Depreciated: This creates a new, empty report XML document
|
||||
* Do NOT use this. Use refobject_new(reportxml_t)
|
||||
*/
|
||||
reportxml_t * reportxml_new(void);
|
||||
/* This gets the root node of a report XML document */
|
||||
reportxml_node_t * reportxml_get_root_node(reportxml_t *report);
|
||||
@ -128,7 +130,9 @@ xmlNodePtr reportxml_node_get_xml_child(reportxml_node_t *node, siz
|
||||
/* The database object is thread safe. */
|
||||
|
||||
|
||||
/* Create a new database object */
|
||||
/* Depreciated: Create a new database object
|
||||
* Do NOT use this. Use refobject_new(reportxml_database_t)
|
||||
*/
|
||||
reportxml_database_t * reportxml_database_new(void);
|
||||
/* Add an report to the database */
|
||||
int reportxml_database_add_report(reportxml_database_t *db, reportxml_t *report);
|
||||
|
Loading…
Reference in New Issue
Block a user