Avoid allocating memory for a thread that don't need it. Also, this memory was not being freed until the

main thread ends. (That is never).

(closes issue #14040)
Reported by: eliel
Patches:
      func_odbc.c.patch uploaded by eliel (license 64)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@161947 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.6.2
Eliel C. Sardanons 17 years ago
parent 390b5bbcd6
commit ec28f57c41

@ -963,7 +963,7 @@ static char *cli_odbc_read(struct ast_cli_entry *e, int cmd, struct ast_cli_args
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(field)[100];
);
struct ast_str *sql = ast_str_thread_get(&sql_buf, 16);
struct ast_str *sql;
char *char_args, varname[10];
struct acf_odbc_query *query;
struct ast_channel *chan;
@ -1005,6 +1005,11 @@ static char *cli_odbc_read(struct ast_cli_entry *e, int cmd, struct ast_cli_args
return CLI_SHOWUSAGE;
}
sql = ast_str_thread_get(&sql_buf, 16);
if (!sql) {
return CLI_FAILURE;
}
AST_RWLIST_RDLOCK(&queries);
AST_RWLIST_TRAVERSE(&queries, query, list) {
if (!strcmp(query->acf->name, a->argv[2])) {
@ -1156,7 +1161,7 @@ static char *cli_odbc_write(struct ast_cli_entry *e, int cmd, struct ast_cli_arg
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(field)[100];
);
struct ast_str *sql = ast_str_thread_get(&sql_buf, 16);
struct ast_str *sql;
char *char_args, *char_values, varname[10];
struct acf_odbc_query *query;
struct ast_channel *chan;
@ -1198,6 +1203,11 @@ static char *cli_odbc_write(struct ast_cli_entry *e, int cmd, struct ast_cli_arg
return CLI_SHOWUSAGE;
}
sql = ast_str_thread_get(&sql_buf, 16);
if (!sql) {
return CLI_FAILURE;
}
AST_RWLIST_RDLOCK(&queries);
AST_RWLIST_TRAVERSE(&queries, query, list) {
if (!strcmp(query->acf->name, a->argv[2])) {

Loading…
Cancel
Save