Cleanup oracle bind allocations.

Mon, 22 Dec 2008 07:52:04 +0000

author
nrich@ii.net
date
Mon, 22 Dec 2008 07:52:04 +0000
changeset 27
1d2369ebee21
parent 26
cf847efefdb5
child 28
44b1d78b50f5

Cleanup oracle bind allocations.

dbd/db2/statement.c file | annotate | diff | comparison | revisions
dbd/oracle/dbd_oracle.h file | annotate | diff | comparison | revisions
dbd/oracle/statement.c file | annotate | diff | comparison | revisions
--- a/dbd/db2/statement.c	Mon Dec 22 07:36:54 2008 +0000
+++ b/dbd/db2/statement.c	Mon Dec 22 07:52:04 2008 +0000
@@ -52,8 +52,10 @@
     if (statement->stmt) {
         SQLFreeStmt(statement->stmt, SQL_CLOSE);
 
-	if (statement->resultset) 
+	if (statement->resultset) {
 	    free(statement->resultset);
+	    statement->resultset = NULL;
+	}
 
 	if (statement->bind) {
 	    int i;
@@ -63,6 +65,7 @@
 	    }
 
 	    free(statement->bind);
+	    statement->bind = NULL;
 	}
 
 	statement->num_result_columns = 0;
--- a/dbd/oracle/dbd_oracle.h	Mon Dec 22 07:36:54 2008 +0000
+++ b/dbd/oracle/dbd_oracle.h	Mon Dec 22 07:52:04 2008 +0000
@@ -34,5 +34,6 @@
     OCIStmt *stmt;
     connection_t *conn;
     int num_columns;
+    bindparams_t *bind;
 } statement_t;
 
--- a/dbd/oracle/statement.c	Mon Dec 22 07:36:54 2008 +0000
+++ b/dbd/oracle/statement.c	Mon Dec 22 07:52:04 2008 +0000
@@ -68,6 +68,11 @@
 	statement->stmt = NULL;
     }
 
+    if (statement->bind) {
+	free(statement->bind);
+	statement->bind = NULL;
+    }
+
     lua_pushboolean(L, ok);
     return 1;
 }
@@ -254,8 +259,9 @@
 	return 0;
     }
 
-    bind = (bindparams_t *)malloc(sizeof(bindparams_t) * statement->num_columns);
-    memset(bind, 0, sizeof(bindparams_t) * statement->num_columns);
+    statement->bind = (bindparams_t *)malloc(sizeof(bindparams_t) * statement->num_columns);
+    memset(statement->bind, 0, sizeof(bindparams_t) * statement->num_columns);
+    bind = statement->bind;
 
     for (i = 0; i < statement->num_columns; i++) {
 	rc = OCIParamGet(statement->stmt, OCI_HTYPE_STMT, statement->conn->err, (dvoid **)&bind[i].param, i+1);
@@ -434,6 +440,7 @@
     statement->conn = conn;
     statement->stmt = stmt;
     statement->num_columns = 0;
+    statement->bind = NULL;
 
     luaL_getmetatable(L, DBD_ORACLE_STATEMENT);
     lua_setmetatable(L, -2);

mercurial