realtime: Centralize some common realtime backend code

All of the realtime backends create artificial ast_categorys to pass
back into the core as query results. These categories have no filename
or line number information associated with them and the backends differ
slightly on how they create them. So create a couple helper macros to
help make things more consistent.

Also updated the call sites to remove redundant error messages about
memory allocation failure.

Note that res_config_ldap sets the category filename to the 'table name'
but that is not read by anything in the core, so I've dropped it.

Change-Id: I3a1fd91e0c807dea1ce3b643b0a6fe5be9002897
This commit is contained in:
Sean Bright
2017-02-21 09:56:54 -05:00
parent 144b09ab41
commit 6e6c96d713
8 changed files with 37 additions and 25 deletions

View File

@@ -182,7 +182,8 @@ static struct ast_config *realtime_multi_curl(const char *url, const char *unuse
continue;
}
if (!(cat = ast_category_new("", "", 99999))) {
cat = ast_category_new_anonymous();
if (!cat) {
continue;
}
@@ -569,8 +570,10 @@ static struct ast_config *config_curl(const char *url, const char *unused, const
}
if (!cat || strcmp(category, cur_cat) || last_cat_metric != cat_metric) {
if (!(cat = ast_category_new(category, "", 99999)))
cat = ast_category_new_dynamic(category);
if (!cat) {
break;
}
cur_cat = category;
last_cat_metric = cat_metric;
ast_category_append(cfg, cat);