Remove SEPARATE_ZVAL_IF_NOT_REF() macro

This macro hasn't made sense since PHP 7. The correct pattern to
use is ZVAL_DEREF + SEPARATE_ZVAL_NOREF.
This commit is contained in:
Nikita Popov 2021-01-14 11:08:44 +01:00
parent aa51785889
commit ec58a6f1b0
3 changed files with 11 additions and 16 deletions

View File

@ -1346,27 +1346,22 @@ static zend_always_inline uint32_t zval_delref_p(zval* pz) {
} while (0)
#define SEPARATE_ARRAY(zv) do { \
zval *_zv = (zv); \
zend_array *_arr = Z_ARR_P(_zv); \
zval *__zv = (zv); \
zend_array *_arr = Z_ARR_P(__zv); \
if (UNEXPECTED(GC_REFCOUNT(_arr) > 1)) { \
if (Z_REFCOUNTED_P(_zv)) { \
if (Z_REFCOUNTED_P(__zv)) { \
GC_DELREF(_arr); \
} \
ZVAL_ARR(_zv, zend_array_dup(_arr)); \
} \
} while (0)
#define SEPARATE_ZVAL_IF_NOT_REF(zv) do { \
zval *__zv = (zv); \
if (Z_TYPE_P(__zv) == IS_ARRAY) { \
SEPARATE_ARRAY(__zv); \
ZVAL_ARR(__zv, zend_array_dup(_arr)); \
} \
} while (0)
#define SEPARATE_ZVAL_NOREF(zv) do { \
zval *_zv = (zv); \
ZEND_ASSERT(Z_TYPE_P(_zv) != IS_REFERENCE); \
SEPARATE_ZVAL_IF_NOT_REF(_zv); \
if (Z_TYPE_P(_zv) == IS_ARRAY) { \
SEPARATE_ARRAY(_zv); \
} \
} while (0)
#define SEPARATE_ZVAL(zv) do { \
@ -1384,7 +1379,9 @@ static zend_always_inline uint32_t zval_delref_p(zval* pz) {
break; \
} \
} \
SEPARATE_ZVAL_IF_NOT_REF(_zv); \
if (Z_TYPE_P(_zv) == IS_ARRAY) { \
SEPARATE_ARRAY(_zv); \
} \
} while (0)
/* Properties store a flag distinguishing unset and uninitialized properties

View File

@ -93,7 +93,7 @@ The following characters also have a meaning in the specifier string:
* `|` - indicates that the remaining parameters are optional, they should be
initialized to default values by the extension since they will not be touched
by the parsing function if they are not passed to it.
* `/` - use SEPARATE_ZVAL_IF_NOT_REF() on the parameter it follows
* `/` - use SEPARATE_ZVAL() on the parameter it follows
* `!` - the parameter it follows can be of specified type or NULL. If NULL is
passed and the output for such type is a pointer, then the output pointer is
set to a native NULL pointer. For 'b', 'l' and 'd', an extra argument of type

View File

@ -359,7 +359,6 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *
} else {
zend_string *str = php_stream_copy_to_mem(stm, PHP_STREAM_COPY_ALL, 0);
if (str != NULL) {
//??SEPARATE_ZVAL_IF_NOT_REF(&param->parameter);
ZVAL_STR(parameter, str);
} else {
ZVAL_EMPTY_STRING(parameter);
@ -381,7 +380,6 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *
S->param_lengths[param->paramno] = 1;
S->param_formats[param->paramno] = 0;
} else {
//SEPARATE_ZVAL_IF_NOT_REF(&param->parameter);
convert_to_string_ex(parameter);
S->param_values[param->paramno] = Z_STRVAL_P(parameter);
S->param_lengths[param->paramno] = Z_STRLEN_P(parameter);