diff options
author | Sean Bright <sean.bright@gmail.com> | 2017-02-21 09:56:54 -0500 |
---|---|---|
committer | Sean Bright <sean.bright@gmail.com> | 2017-02-21 10:53:17 -0600 |
commit | 6e6c96d713be2b745c4e033b6e5710dea72088df (patch) | |
tree | f112d117f05eaf4ea86b4c08317304ddaf20f0b0 /res/res_config_pgsql.c | |
parent | 144b09ab41274498637a6cd8601f653658ecca8b (diff) |
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
Diffstat (limited to 'res/res_config_pgsql.c')
-rw-r--r-- | res/res_config_pgsql.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/res/res_config_pgsql.c b/res/res_config_pgsql.c index f0859617d..b5f24b0f4 100644 --- a/res/res_config_pgsql.c +++ b/res/res_config_pgsql.c @@ -648,8 +648,10 @@ static struct ast_config *realtime_multi_pgsql(const char *database, const char for (rowIndex = 0; rowIndex < num_rows; rowIndex++) { var = NULL; - if (!(cat = ast_category_new("","",99999))) + cat = ast_category_new_anonymous(); + if (!cat) { continue; + } for (i = 0; i < numFields; i++) { stringp = PQgetvalue(result, rowIndex, i); while (stringp) { @@ -1129,9 +1131,10 @@ static struct ast_config *config_pgsql(const char *database, const char *table, } if (strcmp(last, field_category) || last_cat_metric != atoi(field_cat_metric)) { - cur_cat = ast_category_new(field_category, "", 99999); - if (!cur_cat) + cur_cat = ast_category_new_dynamic(field_category); + if (!cur_cat) { break; + } ast_copy_string(last, field_category, sizeof(last)); last_cat_metric = atoi(field_cat_metric); ast_category_append(cfg, cur_cat); |