[svn-commits] eliel: trunk r161947 - /trunk/funcs/func_odbc.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Dec 9 08:49:31 CST 2008


Author: eliel
Date: Tue Dec  9 08:49:30 2008
New Revision: 161947

URL: http://svn.digium.com/view/asterisk?view=rev&rev=161947
Log:
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)

Modified:
    trunk/funcs/func_odbc.c

Modified: trunk/funcs/func_odbc.c
URL: http://svn.digium.com/view/asterisk/trunk/funcs/func_odbc.c?view=diff&rev=161947&r1=161946&r2=161947
==============================================================================
--- trunk/funcs/func_odbc.c (original)
+++ trunk/funcs/func_odbc.c Tue Dec  9 08:49:30 2008
@@ -963,7 +963,7 @@
 	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 @@
 		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 @@
 	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 @@
 		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])) {




More information about the svn-commits mailing list