diff options
author | Xinchen Hui <laruence@php.net> | 2014-06-23 23:01:35 +0800 |
---|---|---|
committer | Xinchen Hui <laruence@php.net> | 2014-06-23 23:33:38 +0800 |
commit | 587923ccc837fc22901f3114631bcc3b1b384fcd (patch) | |
tree | 416c15ea44ac3e7ab96ef5cf70e10cb278b37693 | |
parent | 305da4a88ab1b9a8405c843bf519a19fd039152b (diff) | |
download | php-git-587923ccc837fc22901f3114631bcc3b1b384fcd.tar.gz |
Cleanup (refactoring is finish)
-rw-r--r-- | ext/mysqlnd/mysqlnd_ps.c | 44 | ||||
-rw-r--r-- | ext/mysqlnd/mysqlnd_ps_codec.c | 2 | ||||
-rw-r--r-- | ext/mysqlnd/mysqlnd_result.c | 56 | ||||
-rw-r--r-- | ext/mysqlnd/mysqlnd_wireprotocol.c | 2 |
4 files changed, 3 insertions, 101 deletions
diff --git a/ext/mysqlnd/mysqlnd_ps.c b/ext/mysqlnd/mysqlnd_ps.c index 3885733fa2..adb9578fc8 100644 --- a/ext/mysqlnd/mysqlnd_ps.c +++ b/ext/mysqlnd/mysqlnd_ps.c @@ -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; diff --git a/ext/mysqlnd/mysqlnd_ps_codec.c b/ext/mysqlnd/mysqlnd_ps_codec.c index 5d860f254d..e80aa5565e 100644 --- a/ext/mysqlnd/mysqlnd_ps_codec.c +++ b/ext/mysqlnd/mysqlnd_ps_codec.c @@ -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; diff --git a/ext/mysqlnd/mysqlnd_result.c b/ext/mysqlnd/mysqlnd_result.c index c8313712ba..bc2bbd5df9 100644 --- a/ext/mysqlnd/mysqlnd_result.c +++ b/ext/mysqlnd/mysqlnd_result.c @@ -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)); diff --git a/ext/mysqlnd/mysqlnd_wireprotocol.c b/ext/mysqlnd/mysqlnd_wireprotocol.c index 9beac3d0b2..cf92fa448b 100644 --- a/ext/mysqlnd/mysqlnd_wireprotocol.c +++ b/ext/mysqlnd/mysqlnd_wireprotocol.c @@ -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)); |