Skip to content
Snippets Groups Projects
Commit 4b768281 authored by Joshua Colp's avatar Joshua Colp Committed by Gerrit Code Review
Browse files

Merge "cdr_pgsql.cl: REFACTOR Macro LENGTHEN_BUF"

parents ef293354 2fb45c78
Branches
Tags
No related merge requests found
...@@ -101,35 +101,26 @@ struct columns { ...@@ -101,35 +101,26 @@ struct columns {
static AST_RWLIST_HEAD_STATIC(psql_columns, columns); static AST_RWLIST_HEAD_STATIC(psql_columns, columns);
#define LENGTHEN_BUF1(size) \ #define LENGTHEN_BUF(size, var_sql) \
do { \ do { \
/* Lengthen buffer, if necessary */ \ /* Lengthen buffer, if necessary */ \
if (ast_str_strlen(sql) + size + 1 > ast_str_size(sql)) { \ if (ast_str_strlen(var_sql) + size + 1 > ast_str_size(var_sql)) { \
if (ast_str_make_space(&sql, ((ast_str_size(sql) + size + 3) / 512 + 1) * 512) != 0) { \ if (ast_str_make_space(&var_sql, ((ast_str_size(var_sql) + size + 3) / 512 + 1) * 512) != 0) { \
ast_log(LOG_ERROR, "Unable to allocate sufficient memory. Insert CDR failed.\n"); \ ast_log(LOG_ERROR, "Unable to allocate sufficient memory. Insert CDR '%s:%s' failed.\n", pghostname, table); \
ast_free(sql); \ ast_free(sql); \
ast_free(sql2); \ ast_free(sql2); \
AST_RWLIST_UNLOCK(&psql_columns); \
ast_mutex_unlock(&pgsql_lock); \
return -1; \
} \
} \
} while (0)
#define LENGTHEN_BUF2(size) \
do { \
if (ast_str_strlen(sql2) + size + 1 > ast_str_size(sql2)) { \
if (ast_str_make_space(&sql2, ((ast_str_size(sql2) + size + 3) / 512 + 1) * 512) != 0) { \
ast_log(LOG_ERROR, "Unable to allocate sufficient memory. Insert CDR failed.\n"); \
ast_free(sql); \
ast_free(sql2); \
AST_RWLIST_UNLOCK(&psql_columns); \ AST_RWLIST_UNLOCK(&psql_columns); \
ast_mutex_unlock(&pgsql_lock); \ ast_mutex_unlock(&pgsql_lock); \
return -1; \ return -1; \
} \ } \
} \ } \
} while (0) } while (0)
#define LENGTHEN_BUF1(size) \
LENGTHEN_BUF(size, sql);
#define LENGTHEN_BUF2(size) \
LENGTHEN_BUF(size, sql2);
/*! \brief Handle the CLI command cdr show pgsql status */ /*! \brief Handle the CLI command cdr show pgsql status */
static char *handle_cdr_pgsql_status(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) static char *handle_cdr_pgsql_status(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment