@@ -207,9 +207,9 @@ int php_oci_statement_set_prefetch(php_oci_statement *statement, ub4 prefetch )
207
207
208
208
/* {{{ php_oci_cleanup_pre_fetch()
209
209
Helper function to cleanup ref-cursors and descriptors from the previous row */
210
- int php_oci_cleanup_pre_fetch (void * data )
210
+ int php_oci_cleanup_pre_fetch (zval * data )
211
211
{
212
- php_oci_out_column * outcol = data ;
212
+ php_oci_out_column * outcol = ( php_oci_out_column * ) Z_PTR_P ( data ) ;
213
213
214
214
if (!outcol -> is_descr && !outcol -> is_cursor )
215
215
return ZEND_HASH_APPLY_KEEP ;
@@ -254,7 +254,7 @@ int php_oci_statement_fetch(php_oci_statement *statement, ub4 nrows)
254
254
statement -> errcode = 0 ; /* retain backwards compat with OCI8 1.4 */
255
255
256
256
if (statement -> has_descr && statement -> columns ) {
257
- zend_hash_apply (statement -> columns , ( apply_func_t ) php_oci_cleanup_pre_fetch );
257
+ zend_hash_apply (statement -> columns , php_oci_cleanup_pre_fetch );
258
258
}
259
259
260
260
PHP_OCI_CALL_RETURN (errstatus , OCIStmtFetch , (statement -> stmt , statement -> err , nrows , OCI_FETCH_NEXT , OCI_DEFAULT ));
@@ -479,7 +479,6 @@ sb4 php_oci_define_callback(dvoid *ctx, OCIDefine *define, ub4 iter, dvoid **buf
479
479
int php_oci_statement_execute (php_oci_statement * statement , ub4 mode )
480
480
{
481
481
php_oci_out_column * outcol ;
482
- php_oci_out_column column ;
483
482
OCIParam * param = NULL ;
484
483
text * colname ;
485
484
ub4 counter ;
@@ -530,7 +529,7 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode)
530
529
531
530
if (statement -> binds ) {
532
531
int result = 0 ;
533
- zend_hash_apply_with_argument (statement -> binds , ( apply_func_arg_t ) php_oci_bind_pre_exec , (void * )& result );
532
+ zend_hash_apply_with_argument (statement -> binds , php_oci_bind_pre_exec , (void * )& result );
534
533
if (result ) {
535
534
return 1 ;
536
535
}
@@ -546,7 +545,7 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode)
546
545
}
547
546
548
547
if (statement -> binds ) {
549
- zend_hash_apply (statement -> binds , ( apply_func_t ) php_oci_bind_post_exec );
548
+ zend_hash_apply (statement -> binds , php_oci_bind_post_exec );
550
549
}
551
550
552
551
if (mode & OCI_COMMIT_ON_SUCCESS ) {
@@ -587,9 +586,9 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode)
587
586
statement -> ncolumns = colcount ;
588
587
589
588
for (counter = 1 ; counter <= colcount ; counter ++ ) {
590
- memset ( & column , 0 , sizeof (php_oci_out_column ));
589
+ outcol = ( php_oci_out_column * ) ecalloc ( 1 , sizeof (php_oci_out_column ));
591
590
592
- if ((outcol = zend_hash_index_update_ptr (statement -> columns , counter , & column )) == NULL ) {
591
+ if ((outcol = zend_hash_index_update_ptr (statement -> columns , counter , outcol )) == NULL ) {
593
592
efree (statement -> columns );
594
593
/* out of memory */
595
594
return 1 ;
@@ -902,9 +901,9 @@ void php_oci_statement_free(php_oci_statement *statement)
902
901
903
902
/* {{{ php_oci_bind_pre_exec()
904
903
Helper function */
905
- int php_oci_bind_pre_exec (void * data , void * result )
904
+ int php_oci_bind_pre_exec (zval * data , void * result )
906
905
{
907
- php_oci_bind * bind = (php_oci_bind * ) data ;
906
+ php_oci_bind * bind = (php_oci_bind * ) Z_PTR_P ( data ) ;
908
907
909
908
* (int * )result = 0 ;
910
909
@@ -961,9 +960,9 @@ int php_oci_bind_pre_exec(void *data, void *result)
961
960
962
961
/* {{{ php_oci_bind_post_exec()
963
962
Helper function */
964
- int php_oci_bind_post_exec (void * data )
963
+ int php_oci_bind_post_exec (zval * data )
965
964
{
966
- php_oci_bind * bind = (php_oci_bind * ) data ;
965
+ php_oci_bind * bind = (php_oci_bind * ) Z_PTR_P ( data ) ;
967
966
php_oci_connection * connection = bind -> parent_statement -> connection ;
968
967
sword errstatus ;
969
968
@@ -1317,7 +1316,7 @@ sb4 php_oci_bind_in_callback(
1317
1316
return OCI_ERROR ;
1318
1317
}
1319
1318
1320
- if (ZVAL_IS_NULL (val )) {
1319
+ if (Z_ISNULL_P (val )) {
1321
1320
/* we're going to insert a NULL column */
1322
1321
phpbind -> indicator = -1 ;
1323
1322
* bufpp = 0 ;
@@ -1597,10 +1596,10 @@ int php_oci_bind_array_by_name(php_oci_statement *statement, char *name, int nam
1597
1596
(text * )name ,
1598
1597
name_len ,
1599
1598
(dvoid * ) bindp -> array .elements ,
1600
- (sb4 ) bind -> array .max_length ,
1599
+ (sb4 ) bindp -> array .max_length ,
1601
1600
(ub2 )type ,
1602
1601
(dvoid * )bindp -> array .indicators ,
1603
- (ub2 * )bind -> array .element_lengths ,
1602
+ (ub2 * )bindp -> array .element_lengths ,
1604
1603
(ub2 * )0 , /* bindp->array.retcodes, */
1605
1604
(ub4 ) max_table_length ,
1606
1605
(ub4 * ) & (bindp -> array .current_length ),
@@ -1610,13 +1609,11 @@ int php_oci_bind_array_by_name(php_oci_statement *statement, char *name, int nam
1610
1609
1611
1610
1612
1611
if (errstatus != OCI_SUCCESS ) {
1613
- efree (bind );
1614
1612
statement -> errcode = php_oci_error (statement -> err , errstatus );
1615
1613
PHP_OCI_HANDLE_ERROR (statement -> connection , statement -> errcode );
1616
1614
return 1 ;
1617
1615
}
1618
1616
statement -> errcode = 0 ; /* retain backwards compat with OCI8 1.4 */
1619
- efree (bind );
1620
1617
return 0 ;
1621
1618
}
1622
1619
/* }}} */
@@ -1636,9 +1633,11 @@ php_oci_bind *php_oci_bind_array_helper_string(zval *var, zend_long max_table_le
1636
1633
zend_hash_internal_pointer_reset (hash );
1637
1634
while ((entry = zend_hash_get_current_data (hash )) != NULL ) {
1638
1635
convert_to_string_ex (entry );
1639
- if (Z_STRLEN_P (entry ) > maxlength ) {
1636
+
1637
+ if (maxlength == -1 || Z_STRLEN_P (entry ) > maxlength ) {
1640
1638
maxlength = Z_STRLEN_P (entry ) + 1 ;
1641
1639
}
1640
+
1642
1641
zend_hash_move_forward (hash );
1643
1642
}
1644
1643
}
0 commit comments