diff options
Diffstat (limited to 'cel')
-rw-r--r-- | cel/cel_pgsql.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/cel/cel_pgsql.c b/cel/cel_pgsql.c index 2d7f0dfb0..c5c4fa92b 100644 --- a/cel/cel_pgsql.c +++ b/cel/cel_pgsql.c @@ -71,6 +71,7 @@ static char *pgdbport; static char *table; static int connected = 0; +/* Optimization to reduce number of memory allocations */ static int maxsize = 512, maxsize2 = 512; static int usegmtime = 0; @@ -372,6 +373,14 @@ static void pgsql_log(struct ast_event *event) } PQclear(result); + /* Next time, just allocate buffers that are that big to start with. */ + if (ast_str_strlen(sql) > maxsize) { + maxsize = ast_str_strlen(sql); + } + if (ast_str_strlen(sql2) > maxsize2) { + maxsize2 = ast_str_strlen(sql2); + } + ast_log_cleanup: ast_free(sql); ast_free(sql2); |