summaryrefslogtreecommitdiff
path: root/cel/cel_odbc.c
diff options
context:
space:
mode:
authorRodrigo Ramírez Norambuena <a@rodrigoramirez.com>2015-09-11 03:52:15 -0300
committerRodrigo Ramírez Norambuena <a@rodrigoramirez.com>2015-09-18 12:51:59 -0300
commit99aa7cb26ed851f35a05ab44e6e720b32b8280c2 (patch)
tree83bbde3f6a9312492e05aeac5e5efe65d273ac8a /cel/cel_odbc.c
parent69824fdfbf9c23935f51729ae340a5888cbafd12 (diff)
dr_adaptive_odbc.c, cel_odbc.c, cel_pgsql.c: REFACTOR Macro LENGTHEN_BUF
Remove repeated code on macro of assigned buffer to SQL vars Change-Id: Icb19ad013124498e172ea1d0b29ccd0ed17deef0
Diffstat (limited to 'cel/cel_odbc.c')
-rw-r--r--cel/cel_odbc.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/cel/cel_odbc.c b/cel/cel_odbc.c
index 2d8408baa..3c0be04e8 100644
--- a/cel/cel_odbc.c
+++ b/cel/cel_odbc.c
@@ -341,11 +341,11 @@ static SQLHSTMT generic_prepare(struct odbc_obj *obj, void *data)
return stmt;
}
-#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 + 1) / 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 + 1) / 512 + 1) * 512) != 0) { \
ast_log(LOG_ERROR, "Unable to allocate sufficient memory. Insert CEL '%s:%s' failed.\n", tableptr->connection, tableptr->table); \
ast_free(sql); \
ast_free(sql2); \
@@ -355,18 +355,11 @@ static SQLHSTMT generic_prepare(struct odbc_obj *obj, void *data)
} \
} 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 CEL '%s:%s' failed.\n", tableptr->connection, tableptr->table); \
- ast_free(sql); \
- ast_free(sql2); \
- AST_RWLIST_UNLOCK(&odbc_tables); \
- return; \
- } \
- } \
- } while (0)
+#define LENGTHEN_BUF1(size) \
+ LENGTHEN_BUF(size, sql);
+
+#define LENGTHEN_BUF2(size) \
+ LENGTHEN_BUF(size, sql2);
static void odbc_log(struct ast_event *event)
{