mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Cleanup (refactoring is finish)
This commit is contained in:
parent
305da4a88a
commit
587923ccc8
4 changed files with 3 additions and 101 deletions
|
@ -776,7 +776,6 @@ mysqlnd_stmt_fetch_row_buffered(MYSQLND_RES * result, void * param, unsigned int
|
|||
String of zero size, definitely can't be the next max_length.
|
||||
Thus for NULL and zero-length we are quite efficient.
|
||||
*/
|
||||
//??? if (Z_TYPE(current_row[i]) >= IS_STRING) {
|
||||
if (Z_TYPE(current_row[i]) == IS_STRING) {
|
||||
unsigned long len = Z_STRLEN(current_row[i]);
|
||||
if (meta->fields[i].max_length < len) {
|
||||
|
@ -2025,28 +2024,10 @@ mysqlnd_stmt_separate_result_bind(MYSQLND_STMT * const s TSRMLS_DC)
|
|||
if (stmt->result_bind[i].bound == TRUE) {
|
||||
DBG_INF_FMT("%u has refcount=%u", i,
|
||||
Z_REFCOUNTED(stmt->result_bind[i].zv)? Z_REFCOUNT(stmt->result_bind[i].zv) : 0);
|
||||
/*
|
||||
We have to separate the actual zval value of the bound
|
||||
variable from our allocated zvals or we will face double-free
|
||||
*/
|
||||
if (Z_REFCOUNTED(stmt->result_bind[i].zv) && Z_REFCOUNT(stmt->result_bind[i].zv) > 1) {
|
||||
#ifdef WE_DONT_COPY_IN_BUFFERED_AND_UNBUFFERED_BECAUSEOF_IS_REF
|
||||
Z_TRY_ADDREF_P(&stmt->result_bind[i].zv);
|
||||
#endif
|
||||
zval_ptr_dtor(&stmt->result_bind[i].zv);
|
||||
} else {
|
||||
/*
|
||||
If it is a string, what is pointed will be freed
|
||||
later in free_result(). We need to remove the variable to
|
||||
which the user has lost reference.
|
||||
*/
|
||||
#ifdef WE_DONT_COPY_IN_BUFFERED_AND_UNBUFFERED_BECAUSEOF_IS_REF
|
||||
//??? ZVAL_NULL(&stmt->result_bind[i].zv);
|
||||
#endif
|
||||
zval_ptr_dtor(&stmt->result_bind[i].zv);
|
||||
}
|
||||
zval_ptr_dtor(&stmt->result_bind[i].zv);
|
||||
}
|
||||
}
|
||||
|
||||
s->m->free_result_bind(s, stmt->result_bind TSRMLS_CC);
|
||||
stmt->result_bind = NULL;
|
||||
|
||||
|
@ -2080,26 +2061,7 @@ mysqlnd_stmt_separate_one_result_bind(MYSQLND_STMT * const s, unsigned int param
|
|||
DBG_INF_FMT("%u has refcount=%u", param_no,
|
||||
Z_REFCOUNTED(stmt->result_bind[param_no].zv)?
|
||||
Z_REFCOUNT(stmt->result_bind[param_no].zv) : 0);
|
||||
/*
|
||||
We have to separate the actual zval value of the bound
|
||||
variable from our allocated zvals or we will face double-free
|
||||
*/
|
||||
if (Z_REFCOUNTED(stmt->result_bind[param_no].zv) && Z_REFCOUNT(stmt->result_bind[param_no].zv) > 1) {
|
||||
#ifdef WE_DONT_COPY_IN_BUFFERED_AND_UNBUFFERED_BECAUSEOF_IS_REF
|
||||
Z_TRY_ADDREF_P(&stmt->result_bind[param_no].zv);
|
||||
#endif
|
||||
zval_ptr_dtor(&stmt->result_bind[param_no].zv);
|
||||
} else {
|
||||
/*
|
||||
If it is a string, what is pointed will be freed
|
||||
later in free_result(). We need to remove the variable to
|
||||
which the user has lost reference.
|
||||
*/
|
||||
#ifdef WE_DONT_COPY_IN_BUFFERED_AND_UNBUFFERED_BECAUSEOF_IS_REF
|
||||
//???ZVAL_NULL(&stmt->result_bind[param_no].zv);
|
||||
#endif
|
||||
zval_ptr_dtor(&stmt->result_bind[param_no].zv);
|
||||
}
|
||||
zval_ptr_dtor(&stmt->result_bind[param_no].zv);
|
||||
}
|
||||
|
||||
DBG_VOID_RETURN;
|
||||
|
|
|
@ -506,8 +506,6 @@ mysqlnd_stmt_copy_it(zval ** copies, zval * original, unsigned int param_count,
|
|||
}
|
||||
if (*copies) {
|
||||
ZVAL_COPY(&(*copies)[current], original);
|
||||
//????Z_SET_REFCOUNT_P((*copies)[current], 1);
|
||||
//zval_copy_ctor((*copies)[current]);
|
||||
return PASS;
|
||||
}
|
||||
return FAIL;
|
||||
|
|
|
@ -70,7 +70,6 @@ MYSQLND_METHOD(mysqlnd_result_buffered_zval, initialize_result_set_rest)(MYSQLND
|
|||
String of zero size, definitely can't be the next max_length.
|
||||
Thus for NULL and zero-length we are quite efficient.
|
||||
*/
|
||||
//???? if (Z_TYPE_P(data_cursor[i]) >= IS_STRING) {
|
||||
if (Z_TYPE(data_cursor[i]) == IS_STRING) {
|
||||
unsigned long len = Z_STRLEN(data_cursor[i]);
|
||||
if (meta->fields[i].max_length < len) {
|
||||
|
@ -126,7 +125,6 @@ MYSQLND_METHOD(mysqlnd_result_buffered_c, initialize_result_set_rest)(MYSQLND_RE
|
|||
String of zero size, definitely can't be the next max_length.
|
||||
Thus for NULL and zero-length we are quite efficient.
|
||||
*/
|
||||
//??? if (Z_TYPE(current_row[i]) >= IS_STRING) {
|
||||
if (Z_TYPE(current_row[i]) == IS_STRING) {
|
||||
unsigned long len = Z_STRLEN(current_row[i]);
|
||||
if (meta->fields[i].max_length < len) {
|
||||
|
@ -143,55 +141,6 @@ MYSQLND_METHOD(mysqlnd_result_buffered_c, initialize_result_set_rest)(MYSQLND_RE
|
|||
/* }}} */
|
||||
|
||||
|
||||
#if 0
|
||||
/* {{{ mysqlnd_rset_zval_ptr_dtor */
|
||||
static void
|
||||
mysqlnd_rset_zval_ptr_dtor(zval *zv, enum_mysqlnd_res_type type, zend_bool * copy_ctor_called TSRMLS_DC)
|
||||
{
|
||||
DBG_ENTER("mysqlnd_rset_zval_ptr_dtor");
|
||||
DBG_INF_FMT("type=%u", type);
|
||||
if (!zv) {
|
||||
*copy_ctor_called = FALSE;
|
||||
DBG_ERR_FMT("zv was NULL");
|
||||
DBG_VOID_RETURN;
|
||||
}
|
||||
/*
|
||||
This zval is not from the cache block.
|
||||
Thus the refcount is -1 than of a zval from the cache,
|
||||
because the zvals from the cache are owned by it.
|
||||
*/
|
||||
if (type == MYSQLND_RES_PS_BUF || type == MYSQLND_RES_PS_UNBUF) {
|
||||
*copy_ctor_called = FALSE;
|
||||
; /* do nothing, zval_ptr_dtor will do the job*/
|
||||
} else if (Z_REFCOUNTED_P(zv) && Z_REFCOUNT_P(zv) > 1) {
|
||||
/*
|
||||
Not a prepared statement, then we have to
|
||||
call copy_ctor and then zval_ptr_dtor()
|
||||
*/
|
||||
if (Z_TYPE_P(zv) == IS_STRING) {
|
||||
zval_copy_ctor(zv);
|
||||
}
|
||||
*copy_ctor_called = TRUE;
|
||||
} else {
|
||||
/*
|
||||
noone but us point to this, so we can safely ZVAL_NULL the zval,
|
||||
so Zend does not try to free what the zval points to - which is
|
||||
in result set buffers
|
||||
*/
|
||||
*copy_ctor_called = FALSE;
|
||||
if (Z_TYPE_P(zv) == IS_STRING) {
|
||||
ZVAL_NULL(zv);
|
||||
}
|
||||
}
|
||||
|
||||
DBG_INF_FMT("call the dtor on zval with refc %u", Z_REFCOUNTED_P(zv)? Z_REFCOUNT_P(zv) : 0);
|
||||
zval_ptr_dtor(zv);
|
||||
DBG_VOID_RETURN;
|
||||
}
|
||||
/* }}} */
|
||||
#endif
|
||||
|
||||
|
||||
/* {{{ mysqlnd_result_unbuffered::free_last_data */
|
||||
static void
|
||||
MYSQLND_METHOD(mysqlnd_result_unbuffered, free_last_data)(MYSQLND_RES_UNBUFFERED * unbuf, MYSQLND_STATS * const global_stats TSRMLS_DC)
|
||||
|
@ -206,7 +155,6 @@ MYSQLND_METHOD(mysqlnd_result_unbuffered, free_last_data)(MYSQLND_RES_UNBUFFERED
|
|||
if (unbuf->last_row_data) {
|
||||
unsigned int i;
|
||||
for (i = 0; i < unbuf->field_count; i++) {
|
||||
//???mysqlnd_rset_zval_ptr_dtor(&(unbuf->last_row_data[i]), unbuf->ps ? MYSQLND_RES_PS_UNBUF : MYSQLND_RES_NORMAL, ©_ctor_called TSRMLS_CC);
|
||||
zval_ptr_dtor(&(unbuf->last_row_data[i]));
|
||||
}
|
||||
|
||||
|
@ -1053,7 +1001,6 @@ MYSQLND_METHOD(mysqlnd_result_buffered, fetch_row_c)(MYSQLND_RES * result, void
|
|||
String of zero size, definitely can't be the next max_length.
|
||||
Thus for NULL and zero-length we are quite efficient.
|
||||
*/
|
||||
//???? if (Z_TYPE(current_row[i]) >= IS_STRING) {
|
||||
if (Z_TYPE(current_row[i]) == IS_STRING) {
|
||||
unsigned long len = Z_STRLEN(current_row[i]);
|
||||
if (meta->fields[i].max_length < len) {
|
||||
|
@ -1145,7 +1092,6 @@ MYSQLND_METHOD(mysqlnd_result_buffered_zval, fetch_row)(MYSQLND_RES * result, vo
|
|||
String of zero size, definitely can't be the next max_length.
|
||||
Thus for NULL and zero-length we are quite efficient.
|
||||
*/
|
||||
//???? if (Z_TYPE_P(current_row[i]) >= IS_STRING) {
|
||||
if (Z_TYPE(current_row[i]) == IS_STRING) {
|
||||
unsigned long len = Z_STRLEN(current_row[i]);
|
||||
if (meta->fields[i].max_length < len) {
|
||||
|
@ -1241,7 +1187,6 @@ MYSQLND_METHOD(mysqlnd_result_buffered_c, fetch_row)(MYSQLND_RES * result, void
|
|||
String of zero size, definitely can't be the next max_length.
|
||||
Thus for NULL and zero-length we are quite efficient.
|
||||
*/
|
||||
//???? if (Z_TYPE(current_row[i]) >= IS_STRING) {
|
||||
if (Z_TYPE(current_row[i]) == IS_STRING) {
|
||||
unsigned long len = Z_STRLEN(current_row[i]);
|
||||
if (meta->fields[i].max_length < len) {
|
||||
|
@ -1886,7 +1831,6 @@ MYSQLND_METHOD(mysqlnd_res, fetch_field_data)(MYSQLND_RES * result, unsigned int
|
|||
zend_hash_internal_pointer_reset(Z_ARRVAL(row));
|
||||
while (i++ < offset) {
|
||||
zend_hash_move_forward(Z_ARRVAL(row));
|
||||
//???entry = zend_hash_get_current_data(Z_ARRVAL(row));
|
||||
}
|
||||
|
||||
entry = zend_hash_get_current_data(Z_ARRVAL(row));
|
||||
|
|
|
@ -1630,7 +1630,6 @@ php_mysqlnd_rowp_read_text_protocol_aux(MYSQLND_MEMORY_POOL_CHUNK * row_buffer,
|
|||
#error Need fix for this architecture
|
||||
#endif /* SIZEOF */
|
||||
{
|
||||
//???? ZVAL_STRINGL(current_field, (char *)p, len, 0);
|
||||
ZVAL_STRINGL(current_field, (char *)p, len);
|
||||
} else {
|
||||
ZVAL_LONG(current_field, (long) v); /* the cast is safe */
|
||||
|
@ -1664,7 +1663,6 @@ php_mysqlnd_rowp_read_text_protocol_aux(MYSQLND_MEMORY_POOL_CHUNK * row_buffer,
|
|||
p -= len;
|
||||
if (Z_TYPE_P(current_field) == IS_LONG) {
|
||||
bit_area += 1 + sprintf((char *)start, "%ld", Z_LVAL_P(current_field));
|
||||
//???? ZVAL_STRINGL(current_field, (char *) start, bit_area - start - 1, copy_data);
|
||||
ZVAL_STRINGL(current_field, (char *) start, bit_area - start - 1);
|
||||
} else if (Z_TYPE_P(current_field) == IS_STRING){
|
||||
memcpy(bit_area, Z_STRVAL_P(current_field), Z_STRLEN_P(current_field));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue