Skip to content

Commit

Permalink
Remove ZVAL_NEW_ARR() macro
Browse files Browse the repository at this point in the history
This macro is a footgun because it creates an uninitialized array
(only an allocation). This macro is no longer used in php-src,
and we have better alternatives like array_init() or
ZVAL_ARR(arr, zend_new_array(size_hint)).
  • Loading branch information
nikic committed Jun 7, 2021
1 parent 3f6a9c9 commit e11468a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
2 changes: 2 additions & 0 deletions UPGRADING.INTERNALS
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ PHP 8.1 INTERNALS UPGRADE NOTES
spl_ce_Stringable, spl_ce_Traversable alias class entries have been removed in favor of zend_ce_aggregate,
zend_ce_arrayaccess, zend_ce_countable, zend_ce_iterator, zend_ce_serializable, zend_ce_stringable,
zend_ce_traversable.
- The ZVAL_NEW_ARR() macro has been removed. Use array_init() or ZVAL_ARR
with zend_new_array() instead.
b. Zend Stream API has been changed to use "zend_string*" instead of "char*"
- zend_file_handle.filename now is zend_string*
- zend_file_handle.free_filename is removed. Now zend_file_handle.filename is always released.
Expand Down
8 changes: 0 additions & 8 deletions Zend/zend_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -957,14 +957,6 @@ static zend_always_inline uint32_t zval_gc_info(uint32_t gc_type_info) {
Z_TYPE_INFO_P(__z) = IS_ARRAY_EX; \
} while (0)

#define ZVAL_NEW_ARR(z) do { \
zval *__z = (z); \
zend_array *_arr = \
(zend_array *) emalloc(sizeof(zend_array)); \
Z_ARR_P(__z) = _arr; \
Z_TYPE_INFO_P(__z) = IS_ARRAY_EX; \
} while (0)

#define ZVAL_NEW_PERSISTENT_ARR(z) do { \
zval *__z = (z); \
zend_array *_arr = \
Expand Down

0 comments on commit e11468a

Please sign in to comment.