From c221128351ccfc64c924d79c6809c4e7b18871ff Mon Sep 17 00:00:00 2001 From: CismonX Date: Sun, 26 Aug 2018 20:33:02 +0800 Subject: [PATCH] Compatible with PHP 7.3+ --- src/collections_methods.c | 4 ++-- src/php_collections.h | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/collections_methods.c b/src/collections_methods.c index 21dc535..165bc71 100644 --- a/src/collections_methods.c +++ b/src/collections_methods.c @@ -342,12 +342,12 @@ static zend_always_inline void zend_hash_sort_by(zend_array* ht) { void *new_data, *old_data = HT_GET_DATA_ADDR(ht); Bucket *old_buckets = ht->arData; - new_data = pemalloc(HT_SIZE_EX(ht->nTableSize, HT_MIN_MASK), (ht->u.flags & HASH_FLAG_PERSISTENT)); + new_data = pemalloc(HT_SIZE_EX(ht->nTableSize, HT_MIN_MASK), HT_IS_PERSISTENT(ht)); ht->u.flags |= HASH_FLAG_PACKED | HASH_FLAG_STATIC_KEYS; ht->nTableMask = HT_MIN_MASK; HT_SET_DATA_ADDR(ht, new_data); memcpy(ht->arData, old_buckets, sizeof(Bucket) * ht->nNumUsed); - pefree(old_data, ht->u.flags & HASH_FLAG_PERSISTENT & HASH_FLAG_PERSISTENT); + pefree(old_data, HT_IS_PERSISTENT(ht)); HT_HASH_RESET_PACKED(ht); } } diff --git a/src/php_collections.h b/src/php_collections.h index 10fdea1..081e3ed 100644 --- a/src/php_collections.h +++ b/src/php_collections.h @@ -27,6 +27,9 @@ extern zend_module_entry collections_module_entry; #if PHP_VERSION_ID < 70300 #define GC_ADDREF(p) ++GC_REFCOUNT(p) #define GC_DELREF(p) --GC_REFCOUNT(p) +#define HT_IS_PERSISTENT(ht) (ht)->u.flags & HASH_FLAG_PERSISTENT +#else +#define HT_IS_PERSISTENT(ht) GC_FLAGS(ht) & IS_ARRAY_PERSISTENT #endif #define PHP_COLLECTIONS_COMPARE_NATURAL (1 << 0)