com php-src: Fixed refcount of dbh (we don't need another refcount anymore): ext/pdo/pdo_dbh.c ext/pdo/pdo_stmt.c

From: Date: Fri, 25 Apr 2014 02:27:23 +0000
Subject: com php-src: Fixed refcount of dbh (we don't need another refcount anymore): ext/pdo/pdo_dbh.c ext/pdo/pdo_stmt.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-77293@lists.php.net to get a copy of this message
Commit: 36e214c88b6bdaeecc883b3a80cf7fb3511ec0ac Author: Xinchen Hui <laruence@gmail.com> Fri, 25 Apr 2014 10:27:23 +0800 Parents: e4c59d7f656e020f6aff89c3f0520b69bda0c3fa Branches: phpng Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=36e214c88b6bdaeecc883b3a80cf7fb3511ec0ac Log: Fixed refcount of dbh (we don't need another refcount anymore) Changed paths: M ext/pdo/pdo_dbh.c M ext/pdo/pdo_stmt.c Diff: diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c index 90ee44f..f75738c 100644 --- a/ext/pdo/pdo_dbh.c +++ b/ext/pdo/pdo_dbh.c @@ -579,9 +579,8 @@ static PHP_METHOD(PDO, prepare) stmt->default_fetch_type = dbh->default_fetch_type; stmt->dbh = dbh; /* give it a reference to me */ - Z_ADDREF_P(getThis()); - php_pdo_dbh_addref(dbh TSRMLS_CC); - ZVAL_COPY_VALUE(&stmt->database_object_handle, getThis()); + ZVAL_OBJ(&stmt->database_object_handle, &dbh->std); + Z_ADDREF(stmt->database_object_handle); /* we haven't created a lazy object yet */ ZVAL_UNDEF(&stmt->lazy_object_ref); @@ -1118,9 +1117,8 @@ static PHP_METHOD(PDO, query) stmt->active_query_stringlen = statement_len; stmt->dbh = dbh; /* give it a reference to me */ - Z_ADDREF_P(getThis()); - php_pdo_dbh_addref(dbh TSRMLS_CC); - stmt->database_object_handle = *getThis(); + ZVAL_OBJ(&stmt->database_object_handle, &dbh->std); + Z_ADDREF(stmt->database_object_handle); /* we haven't created a lazy object yet */ ZVAL_UNDEF(&stmt->lazy_object_ref); @@ -1150,7 +1148,7 @@ static PHP_METHOD(PDO, query) PDO_HANDLE_STMT_ERR(); } else { PDO_HANDLE_DBH_ERR(); - zval_dtor(return_value); + zval_ptr_dtor(return_value); } RETURN_FALSE; @@ -1507,11 +1505,8 @@ static void dbh_free(pdo_dbh_t *dbh TSRMLS_DC) { int i; - if (--dbh->refcount) - return; - if (dbh->query_stmt) { - zval_dtor(&dbh->query_stmt_zval); + zval_ptr_dtor(&dbh->query_stmt_zval); dbh->query_stmt = NULL; } @@ -1547,16 +1542,6 @@ static void dbh_free(pdo_dbh_t *dbh TSRMLS_DC) //???pefree(dbh, dbh->is_persistent); } -PDO_API void php_pdo_dbh_addref(pdo_dbh_t *dbh TSRMLS_DC) -{ - dbh->refcount++; -} - -PDO_API void php_pdo_dbh_delref(pdo_dbh_t *dbh TSRMLS_DC) -{ - dbh_free(dbh TSRMLS_CC); -} - static void pdo_dbh_free_storage(zend_object *std TSRMLS_DC) { pdo_dbh_t *dbh = php_pdo_dbh_fetch_object(std); diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index 65ac8a8..689de9b 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -2271,8 +2271,6 @@ static zend_object *dbstmt_clone_obj(zval *zobject TSRMLS_DC) zend_objects_clone_members(&stmt->std, &old_stmt->std TSRMLS_CC); - ZVAL_COPY(&stmt->database_object_handle, &old_stmt->database_object_handle); - return &stmt->std; } @@ -2352,9 +2350,8 @@ static void free_statement(pdo_stmt_t *stmt TSRMLS_DC) do_fetch_opt_finish(stmt, 1 TSRMLS_CC); - zval_ptr_dtor(&stmt->database_object_handle); - if (stmt->dbh) { - php_pdo_dbh_delref(stmt->dbh TSRMLS_CC); + if (!ZVAL_IS_UNDEF(&stmt->database_object_handle)) { + zval_ptr_dtor(&stmt->database_object_handle); } zend_object_std_dtor(&stmt->std TSRMLS_CC); }

« previous php.cvs (#77293) next »