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 f29ea24d9f
commit 5eb7875243
8 changed files with 37 additions and 25 deletions

View File

@@ -505,7 +505,8 @@ static int append_row_to_cfg(void *arg, int num_columns, char **values, char **c
struct ast_category *cat;
int i;
if (!(cat = ast_category_new("", "", 99999))) {
cat = ast_category_new_anonymous();
if (!cat) {
return SQLITE_ABORT;
}
@@ -725,8 +726,8 @@ static int static_realtime_cb(void *arg, int num_columns, char **values, char **
}
if (!args->cat_name || strcmp(args->cat_name, values[COL_CATEGORY])) {
if (!(args->cat = ast_category_new(values[COL_CATEGORY], "", 99999))) {
ast_log(LOG_WARNING, "Unable to allocate category\n");
args->cat = ast_category_new_dynamic(values[COL_CATEGORY]);
if (!args->cat) {
return SQLITE_ABORT;
}