cvs: /php4/ext/odbc php_odbc.h php_odbc.c
| From: | Leo Baschy | Date: | Thu, 09 Mar 2000 22:20:27 +0000 |
| Subject: | cvs: /php4/ext/odbc php_odbc.h php_odbc.c | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-11829@lists.php.net to get a copy of this message | ||
codelion Thu Mar 9 14:20:27 2000 EDT
Modified files:
/php4/ext/odbc php_odbc.h php_odbc.c
Log:
_close_odbc_conn calls _free_odbc_result if possible
Index: php4/ext/odbc/php_odbc.h
diff -u php4/ext/odbc/php_odbc.h:1.16 php4/ext/odbc/php_odbc.h:1.17
--- php4/ext/odbc/php_odbc.h:1.16 Wed Feb 23 11:16:34 2000
+++ php4/ext/odbc/php_odbc.h Thu Mar 9 14:19:57 2000
@@ -28,7 +28,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_odbc.h,v 1.16 2000/02/23 19:16:34 sas Exp $ */
+/* $Id: php_odbc.h,v 1.17 2000/03/09 22:19:57 codelion Exp $ */
#ifndef _PHP_ODBC_H
#define _PHP_ODBC_H
@@ -218,6 +218,7 @@
/* int open;*/
int id;
int persistent;
+ struct odbc_result *one_result; // to enable _close_odbc_conn to call _free_odbc_result
} odbc_connection;
typedef struct odbc_result_value {
Index: php4/ext/odbc/php_odbc.c
diff -u php4/ext/odbc/php_odbc.c:1.32 php4/ext/odbc/php_odbc.c:1.33
--- php4/ext/odbc/php_odbc.c:1.32 Mon Mar 6 10:41:13 2000
+++ php4/ext/odbc/php_odbc.c Thu Mar 9 14:19:57 2000
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_odbc.c,v 1.32 2000/03/06 18:41:13 ssb Exp $ */
+/* $Id: php_odbc.c,v 1.33 2000/03/09 22:19:57 codelion Exp $ */
#if COMPILE_DL
#include "dl/phpdl.h"
@@ -160,10 +160,18 @@
* zend_list_delete(res->conn_ptr->id);
*/
}
+ if (res->conn_ptr) {
+ if (res->conn_ptr->one_result == res) {
+ res->conn_ptr->one_result = NULL;
+ };
+ };
efree(res);
}
}
+#define ODBC_REGISTER_RESULT_WITH_CONNECTION(result) if (!((result)->conn_ptr->one_result)) {
\
+ (result)->conn_ptr->one_result = (result); };
+
static void _close_odbc_conn(odbc_connection *conn)
{
/* FIXME
@@ -173,6 +181,10 @@
*/
ODBCLS_FETCH();
+ if (conn->one_result) {
+ zend_list_delete(conn->one_result->id);
+ conn->one_result = NULL;
+ };
SQLDisconnect(conn->hdbc);
SQLFreeConnect(conn->hdbc);
SQLFreeEnv(conn->henv);
@@ -184,6 +196,10 @@
{
ODBCLS_FETCH();
+ if (conn->one_result) {
+ zend_list_delete(conn->one_result->id);
+ conn->one_result = NULL;
+ };
SQLDisconnect(conn->hdbc);
SQLFreeConnect(conn->hdbc);
SQLFreeEnv(conn->henv);
@@ -688,6 +704,7 @@
zend_list_addref(conn->id);
result->conn_ptr = conn;
result->fetched = 0;
+ ODBC_REGISTER_RESULT_WITH_CONNECTION(result);
RETURN_RESOURCE(result->id);
}
/* }}} */
@@ -1017,6 +1034,7 @@
zend_list_addref(conn->id);
result->conn_ptr = conn;
result->fetched = 0;
+ ODBC_REGISTER_RESULT_WITH_CONNECTION(result);
RETURN_RESOURCE(result->id);
}
@@ -1583,6 +1601,7 @@
*conn = (odbc_connection *)pemalloc(sizeof(odbc_connection), persistent);
(*conn)->persistent = persistent;
+ (*conn)->one_result = NULL;
SQLAllocEnv(&((*conn)->henv));
SQLAllocConnect((*conn)->henv, &((*conn)->hdbc));
@@ -2251,6 +2270,7 @@
}
result->conn_ptr = conn;
result->fetched = 0;
+ ODBC_REGISTER_RESULT_WITH_CONNECTION(result);
ZEND_REGISTER_RESOURCE(return_value, result, le_result);
}
/* }}} */
@@ -2333,6 +2353,7 @@
}
result->conn_ptr = conn;
result->fetched = 0;
+ ODBC_REGISTER_RESULT_WITH_CONNECTION(result);
ZEND_REGISTER_RESOURCE(return_value, result, le_result);
}
/* }}} */
@@ -2412,6 +2433,7 @@
}
result->conn_ptr = conn;
result->fetched = 0;
+ ODBC_REGISTER_RESULT_WITH_CONNECTION(result);
ZEND_REGISTER_RESOURCE(return_value, result, le_result);
}
/* }}} */
@@ -2512,6 +2534,7 @@
}
result->conn_ptr = conn;
result->fetched = 0;
+ ODBC_REGISTER_RESULT_WITH_CONNECTION(result);
ZEND_REGISTER_RESOURCE(return_value, result, le_result);
}
/* }}} */
@@ -2585,6 +2608,7 @@
}
result->conn_ptr = conn;
result->fetched = 0;
+ ODBC_REGISTER_RESULT_WITH_CONNECTION(result);
ZEND_REGISTER_RESOURCE(return_value, result, le_result);
}
/* }}} */
@@ -2660,6 +2684,7 @@
}
result->conn_ptr = conn;
result->fetched = 0;
+ ODBC_REGISTER_RESULT_WITH_CONNECTION(result);
ZEND_REGISTER_RESOURCE(return_value, result, le_result);
}
/* }}} */
@@ -2743,6 +2768,7 @@
}
result->conn_ptr = conn;
result->fetched = 0;
+ ODBC_REGISTER_RESULT_WITH_CONNECTION(result);
ZEND_REGISTER_RESOURCE(return_value, result, le_result);
}
/* }}} */
@@ -2824,6 +2850,7 @@
}
result->conn_ptr = conn;
result->fetched = 0;
+ ODBC_REGISTER_RESULT_WITH_CONNECTION(result);
ZEND_REGISTER_RESOURCE(return_value, result, le_result);
}
/* }}} */
@@ -2913,6 +2940,7 @@
}
result->conn_ptr = conn;
result->fetched = 0;
+ ODBC_REGISTER_RESULT_WITH_CONNECTION(result);
ZEND_REGISTER_RESOURCE(return_value, result, le_result);
}
/* }}} */
@@ -2997,6 +3025,7 @@
}
result->conn_ptr = conn;
result->fetched = 0;
+ ODBC_REGISTER_RESULT_WITH_CONNECTION(result);
ZEND_REGISTER_RESOURCE(return_value, result, le_result);
}
/* }}} */
@@ -3073,6 +3102,7 @@
}
result->conn_ptr = conn;
result->fetched = 0;
+ ODBC_REGISTER_RESULT_WITH_CONNECTION(result);
ZEND_REGISTER_RESOURCE(return_value, result, le_result);
}
/* }}} */