Skip to content

Commit

Permalink
Remove SEPARATE_ZVAL_IF_NOT_REF() macro
Browse files Browse the repository at this point in the history
This macro hasn't made sense since PHP 7. The correct pattern to
use is ZVAL_DEREF + SEPARATE_ZVAL_NOREF.
  • Loading branch information
nikic committed Jan 14, 2021
1 parent aa51785 commit ec58a6f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
23 changes: 10 additions & 13 deletions Zend/zend_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 { \
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/parameter-parsing-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions ext/pdo_pgsql/pgsql_statement.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit ec58a6f

Please sign in to comment.