[Freeswitch-svn] [commit] r5955 - freeswitch/trunk/src

Freeswitch SVN anthm at freeswitch.org
Wed Oct 17 20:10:49 EDT 2007


Author: anthm
Date: Wed Oct 17 20:10:48 2007
New Revision: 5955

Modified:
   freeswitch/trunk/src/switch_odbc.c

Log:
umm, duh

Modified: freeswitch/trunk/src/switch_odbc.c
==============================================================================
--- freeswitch/trunk/src/switch_odbc.c	(original)
+++ freeswitch/trunk/src/switch_odbc.c	Wed Oct 17 20:10:48 2007
@@ -305,7 +305,7 @@
 {
 	SQLHSTMT stmt = NULL;
 	SQLSMALLINT c = 0, x = 0;
-	SQLINTEGER m = 0;
+	SQLINTEGER m = 0, t = 0;
 	int result;
 
 	assert(callback != NULL);
@@ -333,43 +333,47 @@
 	SQLRowCount(stmt, &m);
 
 	if (m > 0) {
-		int name_len = 256;
-		char **names;
-		char **vals;
-		int y = 0;
+		for (t = 0; t < m; t++) {
+			int name_len = 256;
+			char **names;
+			char **vals;
+			int y = 0;
 		
-		if (!(result = SQLFetch(stmt)) == SQL_SUCCESS) {
-			goto error;
-		}
-		
-		names = calloc(c, sizeof(*names));
-		vals = calloc(c, sizeof(*names));
+			if (!(result = SQLFetch(stmt)) == SQL_SUCCESS) {
+				goto error;
+			}
 		
-		assert(names && vals);
+			names = calloc(c, sizeof(*names));
+			vals = calloc(c, sizeof(*vals));
 		
-		for (x = 1; x <= c; x++) {
-			SQLSMALLINT NameLength, DataType, DecimalDigits, Nullable;
-			SQLUINTEGER ColumnSize;
-			names[y] = malloc(name_len);
-			memset(names[y], 0, name_len);
-
-			SQLDescribeCol(stmt, x, (SQLCHAR *) names[y], (SQLSMALLINT)name_len, &NameLength, &DataType, &ColumnSize, &DecimalDigits, &Nullable);
-			ColumnSize++;
-
-			vals[y] = malloc(ColumnSize);
-			memset(vals[y], 0, ColumnSize);
-			SQLGetData(stmt, x, SQL_C_CHAR, (SQLCHAR *) vals[y], ColumnSize, NULL);
-			y++;
-		}
-		
-		callback(pdata, y, vals, names);
+			assert(names && vals);
 
-		for (x = 0; x < y; x++) {
-			free(names[x]);
-			free(vals[x]);
+			for (x = 1; x <= c; x++) {
+				SQLSMALLINT NameLength, DataType, DecimalDigits, Nullable;
+				SQLUINTEGER ColumnSize;
+				names[y] = malloc(name_len);
+				memset(names[y], 0, name_len);
+
+				SQLDescribeCol(stmt, x, (SQLCHAR *) names[y], (SQLSMALLINT)name_len, &NameLength, &DataType, &ColumnSize, &DecimalDigits, &Nullable);
+				ColumnSize++;
+
+				vals[y] = malloc(ColumnSize);
+				memset(vals[y], 0, ColumnSize);
+				SQLGetData(stmt, x, SQL_C_CHAR, (SQLCHAR *) vals[y], ColumnSize, NULL);
+				y++;
+			}
+		
+			if (callback(pdata, y, vals, names)) {
+				break;
+			}
+
+			for (x = 0; x < y; x++) {
+				free(names[x]);
+				free(vals[x]);
+			}
+			free(names);
+			free(vals);
 		}
-		free(names);
-		free(vals);
 	}
 
 	SQLFreeHandle(SQL_HANDLE_STMT, stmt);



More information about the Freeswitch-svn mailing list