summaryrefslogtreecommitdiff
path: root/cel/cel_pgsql.c
diff options
context:
space:
mode:
Diffstat (limited to 'cel/cel_pgsql.c')
-rw-r--r--cel/cel_pgsql.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/cel/cel_pgsql.c b/cel/cel_pgsql.c
index f4959474a..e4e280e41 100644
--- a/cel/cel_pgsql.c
+++ b/cel/cel_pgsql.c
@@ -100,11 +100,11 @@ struct columns {
static AST_RWLIST_HEAD_STATIC(psql_columns, columns);
-#define LENGTHEN_BUF1(size) \
+#define LENGTHEN_BUF(size, var_sql) \
do { \
/* Lengthen buffer, if necessary */ \
- if (ast_str_strlen(sql) + size + 1 > ast_str_size(sql)) { \
- if (ast_str_make_space(&sql, ((ast_str_size(sql) + size + 3) / 512 + 1) * 512) != 0) { \
+ if (ast_str_strlen(var_sql) + size + 1 > ast_str_size(var_sql)) { \
+ 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 CEL '%s:%s' failed.\n", pghostname, table); \
ast_free(sql); \
ast_free(sql2); \
@@ -114,18 +114,10 @@ static AST_RWLIST_HEAD_STATIC(psql_columns, columns);
} \
} while (0)
+#define LENGTHEN_BUF1(size) \
+ LENGTHEN_BUF(size, sql);
#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 CEL '%s:%s' failed.\n", pghostname, table); \
- ast_free(sql); \
- ast_free(sql2); \
- AST_RWLIST_UNLOCK(&psql_columns); \
- return; \
- } \
- } \
- } while (0)
+ LENGTHEN_BUF(size, sql2);
static void pgsql_reconnect(void)
{