com php-src: More PHP 7 patches (Rajendra/Abdullah): ext/oci8/oci8.c ext/oci8/oci8_interface.c ext/oci8/oci8_stateme nt.c
| From: | Christopher Jones | Date: | Tue, 30 Jun 2015 03:54:40 +0000 |
| Subject: | com php-src: More PHP 7 patches (Rajendra/Abdullah): ext/oci8/oci8.c ext/oci8/oci8_interface.c ext/oci8/oci8_stateme nt.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-87639@lists.php.net to get a copy of this message | ||
Commit: 99cac5055e8f4cb6644520ba398c1fc418237e4a
Author: Christopher Jones <christopher.jones@oracle.com> Tue, 30 Jun 2015 13:54:40
+1000
Parents: 6ad9cd5367734276d624d6d2a03406ed0d0cd08b
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=99cac5055e8f4cb6644520ba398c1fc418237e4a
Log:
More PHP 7 patches (Rajendra/Abdullah)
Changed paths:
M ext/oci8/oci8.c
M ext/oci8/oci8_interface.c
M ext/oci8/oci8_statement.c
Diff:
diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c
index 0492cdb..f431dca 100644
--- a/ext/oci8/oci8.c
+++ b/ext/oci8/oci8.c
@@ -1562,8 +1562,8 @@ void php_oci_bind_hash_dtor(zval *data)
if (bind->array.indicators) {
efree(bind->array.indicators);
}
-
- zval_ptr_dtor(&bind->zval);
+ efree(bind);
+ /*zval_ptr_dtor(&bind->zval); */
}
/* }}} */
@@ -1590,6 +1590,8 @@ void php_oci_column_hash_dtor(zval *data)
if (column->name) {
efree(column->name);
}
+
+ efree(column);
}
/* }}} */
diff --git a/ext/oci8/oci8_interface..c b/ext/oci8/oci8_interface.c
index 4deaec6..bccab92 100644
--- a/ext/oci8/oci8_interface.c
+++ b/ext/oci8/oci8_interface.c
@@ -55,6 +55,7 @@ PHP_FUNCTION(oci_define_by_name)
zend_long type = 0;
php_oci_statement *statement;
php_oci_define *define, *tmp_define;
+ zend_string *zvtmp;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rsz/|l", &stmt, &name,
&name_len, &var, &type) == FAILURE) {
return;
@@ -74,12 +75,15 @@ PHP_FUNCTION(oci_define_by_name)
define = ecalloc(1,sizeof(php_oci_define));
- //if (zend_hash_add(statement->defines, name, name_len, define, sizeof(php_oci_define), (void
**)&tmp_define) == SUCCESS) {
- if ((tmp_define = zend_hash_add_new_ptr(statement->defines, zend_string_init(name, name_len,
0), define)) != NULL) {
+ /* if (zend_hash_add(statement->defines, name, name_len, define, sizeof(php_oci_define), (void
**)&tmp_define) == SUCCESS) { */
+ zvtmp = zend_string_init(name, name_len, 0);
+ if ((tmp_define = zend_hash_add_new_ptr(statement->defines, zvtmp, define)) != NULL) {
efree(define);
+ zend_string_release(zvtmp);
define = tmp_define;
} else {
efree(define);
+ zend_string_release(zvtmp);
RETURN_FALSE;
}
@@ -1429,7 +1433,10 @@ PHP_FUNCTION(oci_fetch_all)
if (flags & PHP_OCI_NUM) {
zend_hash_next_index_insert(Z_ARRVAL(row), &element);
} else { /* default to ASSOC */
- zend_symtable_update(Z_ARRVAL(row), zend_string_init(columns[ i ]->name, columns[ i
]->name_len, 0), &element);
+ zend_string *zvtmp;
+ zvtmp = zend_string_init(columns[ i ]->name, columns[ i ]->name_len, 0);
+ zend_symtable_update(Z_ARRVAL(row), zvtmp, &element);
+ zend_string_release(zvtmp);
}
}
@@ -1456,10 +1463,13 @@ PHP_FUNCTION(oci_fetch_all)
}
} else { /* default to ASSOC */
for (i = 0; i < statement->ncolumns; i++) {
+ zend_string *zvtmp;
columns[ i ] = php_oci_statement_get_column(statement, i + 1, NULL, 0);
array_init(&tmp);
- outarrs[ i ] = zend_symtable_update(Z_ARRVAL_P(array), zend_string_init(columns[ i ]->name,
columns[ i ]->name_len, 0), &tmp);
+ zvtmp = zend_string_init(columns[ i ]->name, columns[ i ]->name_len, 0);
+ outarrs[ i ] = zend_symtable_update(Z_ARRVAL_P(array), zvtmp, &tmp);
+ zend_string_release(zvtmp);
}
}
@@ -1657,7 +1667,7 @@ go_out:
if (errcode) {
array_init(return_value);
add_assoc_long(return_value, "code", errcode);
- // TODO: avoid reallocation ???
+ /* TODO: avoid reallocation ??? */
add_assoc_string(return_value, "message", (char*) errbuf);
efree(errbuf);
add_assoc_long(return_value, "offset", error_offset);
diff --git a/ext/oci8/oci8_statement.c b/ext/oci8/oci8_statement.c
index ef68f1c..3f5e826 100644
--- a/ext/oci8/oci8_statement.c
+++ b/ext/oci8/oci8_statement.c
@@ -589,7 +589,7 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode)
outcol = (php_oci_out_column *) ecalloc(1, sizeof(php_oci_out_column));
if ((outcol = zend_hash_index_update_ptr(statement->columns, counter, outcol)) == NULL) {
- efree(statement->columns);
+ FREE_HASHTABLE(statement->columns);
/* out of memory */
return 1;
}
@@ -875,17 +875,17 @@ void php_oci_statement_free(php_oci_statement *statement)
if (statement->columns) {
zend_hash_destroy(statement->columns);
- efree(statement->columns);
+ FREE_HASHTABLE(statement->columns);
}
if (statement->binds) {
zend_hash_destroy(statement->binds);
- efree(statement->binds);
+ FREE_HASHTABLE(statement->binds);
}
if (statement->defines) {
zend_hash_destroy(statement->defines);
- efree(statement->defines);
+ FREE_HASHTABLE(statement->defines);
}
if (statement->parent_stmtid) {
@@ -1210,12 +1210,15 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, int
name_len,
zend_hash_init(statement->binds, 13, NULL, php_oci_bind_hash_dtor, 0);
}
- memset((void*)&bind,0,sizeof(php_oci_bind));
if ((old_bind = zend_hash_str_find_ptr(statement->binds, name, name_len)) != NULL) {
bindp = old_bind;
zval_ptr_dtor(&bindp->zval);
} else {
- bindp = zend_hash_update_ptr(statement->binds, zend_string_init(name, name_len + 1, 0),
&bind);
+ zend_string *zvtmp;
+ zvtmp = zend_string_init(name, name_len + 1, 0);
+ bindp = (php_oci_bind *) ecalloc(1, sizeof(php_oci_bind));
+ bindp = zend_hash_update_ptr(statement->binds, zvtmp, bindp);
+ zend_string_release(zvtmp);
}
bindp->descriptor = oci_desc;
@@ -1223,7 +1226,7 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, int
name_len,
bindp->parent_statement = statement;
ZVAL_COPY(&bindp->zval, var);
bindp->type = type;
- Z_ADDREF_P(var);
+ Z_TRY_ADDREF_P(var);
PHP_OCI_CALL_RETURN(errstatus,
OCIBindByName,
@@ -1407,10 +1410,12 @@ sb4 php_oci_bind_out_callback(
} else {
convert_to_string(val);
zval_dtor(val);
-
- //Z_STRLEN_P(val) = PHP_OCI_PIECE_SIZE; /* 64K-1 is max XXX */
- //Z_STRVAL_P(val) = ecalloc(1, Z_STRLEN_P(phpbind->zval) + 1);
- // XXX is this right?
+
+#if 0
+ Z_STRLEN_P(val) = PHP_OCI_PIECE_SIZE; /* 64K-1 is max XXX */
+ Z_STRVAL_P(val) = ecalloc(1, Z_STRLEN_P(phpbind->zval) + 1);
+ /* XXX is this right? */
+#endif
ZVAL_STRINGL(val, NULL, Z_STRLEN(phpbind->zval) + 1);
/* XXX we assume that zend-zval len has 4 bytes */
@@ -1524,6 +1529,7 @@ int php_oci_bind_array_by_name(php_oci_statement *statement, char *name, int
nam
{
php_oci_bind *bind, *bindp;
sword errstatus;
+ zend_string *zvtmp;
convert_to_array(var);
@@ -1574,7 +1580,9 @@ int php_oci_bind_array_by_name(php_oci_statement *statement, char *name, int
nam
zend_hash_init(statement->binds, 13, NULL, php_oci_bind_hash_dtor, 0);
}
- bindp = zend_hash_update_ptr(statement->binds, zend_string_init(name, name_len + 1, 0), bind);
+ zvtmp = zend_string_init(name, name_len + 1, 0);
+ bindp = zend_hash_update_ptr(statement->binds, zvtmp, bind);
+ zend_string_release(zvtmp);
bindp->descriptor = NULL;
bindp->statement = NULL;