Skip to content

Commit 1b2ec73

Browse files
committed
Drop various unused macros/APIs
Also convert_libmagic_pattern() to return a zend_string* Closes GH-6029
1 parent ebbe333 commit 1b2ec73

26 files changed

+111
-114
lines changed

UPGRADING.INTERNALS

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ PHP 8.0 INTERNALS UPGRADE NOTES
2222
s. zend_fcall_info no_separation flag removed
2323
t. Signature changes
2424
u. Error Notification callbacks to replace zend_error_cb overwrite use-cases
25+
v. Removed Zend APIs
2526

2627
2. Build system changes
2728
a. Abstract
@@ -201,6 +202,17 @@ PHP 8.0 INTERNALS UPGRADE NOTES
201202
}
202203
zend_register_error_notify_callback(my_error_notify_cb);
203204

205+
v. The following APIs have been removed from the Zend Engine:
206+
- zend_ts_hash_init_ex(), drop the last argument and use zend_ts_hash_init() instead
207+
- zend_hash_init_ex(), drop the last argument and use zend_hash_init() instead
208+
- zval_internal_dtor(), use zval_internal_ptr_dtor() instead
209+
- zval_dtor_func(), use rc_dtor_func() instead
210+
- zval_ptr_dtor_wrapper(), use zval_ptr_dtor() instead
211+
- zval_internal_ptr_dtor_wrapper(), use zval_internal_ptr_dtor() instead
212+
213+
w. The following APIs have been renamed:
214+
- _zend_ts_hash_init() to zend_ts_hash_init()
215+
204216
========================
205217
2. Build system changes
206218
========================

Zend/zend.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -650,17 +650,17 @@ static void compiler_globals_ctor(zend_compiler_globals *compiler_globals) /* {{
650650
compiler_globals->compiled_filename = NULL;
651651

652652
compiler_globals->function_table = (HashTable *) malloc(sizeof(HashTable));
653-
zend_hash_init_ex(compiler_globals->function_table, 1024, NULL, ZEND_FUNCTION_DTOR, 1, 0);
653+
zend_hash_init(compiler_globals->function_table, 1024, NULL, ZEND_FUNCTION_DTOR, 1);
654654
zend_hash_copy(compiler_globals->function_table, global_function_table, function_copy_ctor);
655655

656656
compiler_globals->class_table = (HashTable *) malloc(sizeof(HashTable));
657-
zend_hash_init_ex(compiler_globals->class_table, 64, NULL, ZEND_CLASS_DTOR, 1, 0);
657+
zend_hash_init(compiler_globals->class_table, 64, NULL, ZEND_CLASS_DTOR, 1);
658658
zend_hash_copy(compiler_globals->class_table, global_class_table, zend_class_add_ref);
659659

660660
zend_set_default_compile_time_values();
661661

662662
compiler_globals->auto_globals = (HashTable *) malloc(sizeof(HashTable));
663-
zend_hash_init_ex(compiler_globals->auto_globals, 8, NULL, auto_global_dtor, 1, 0);
663+
zend_hash_init(compiler_globals->auto_globals, 8, NULL, auto_global_dtor, 1);
664664
zend_hash_copy(compiler_globals->auto_globals, global_auto_globals_table, auto_global_copy_ctor);
665665

666666
compiler_globals->script_encoding_list = NULL;
@@ -894,12 +894,12 @@ int zend_startup(zend_utility_functions *utility_functions) /* {{{ */
894894
GLOBAL_AUTO_GLOBALS_TABLE = (HashTable *) malloc(sizeof(HashTable));
895895
GLOBAL_CONSTANTS_TABLE = (HashTable *) malloc(sizeof(HashTable));
896896

897-
zend_hash_init_ex(GLOBAL_FUNCTION_TABLE, 1024, NULL, ZEND_FUNCTION_DTOR, 1, 0);
898-
zend_hash_init_ex(GLOBAL_CLASS_TABLE, 64, NULL, ZEND_CLASS_DTOR, 1, 0);
899-
zend_hash_init_ex(GLOBAL_AUTO_GLOBALS_TABLE, 8, NULL, auto_global_dtor, 1, 0);
900-
zend_hash_init_ex(GLOBAL_CONSTANTS_TABLE, 128, NULL, ZEND_CONSTANT_DTOR, 1, 0);
897+
zend_hash_init(GLOBAL_FUNCTION_TABLE, 1024, NULL, ZEND_FUNCTION_DTOR, 1);
898+
zend_hash_init(GLOBAL_CLASS_TABLE, 64, NULL, ZEND_CLASS_DTOR, 1);
899+
zend_hash_init(GLOBAL_AUTO_GLOBALS_TABLE, 8, NULL, auto_global_dtor, 1);
900+
zend_hash_init(GLOBAL_CONSTANTS_TABLE, 128, NULL, ZEND_CONSTANT_DTOR, 1);
901901

902-
zend_hash_init_ex(&module_registry, 32, NULL, module_destructor_zval, 1, 0);
902+
zend_hash_init(&module_registry, 32, NULL, module_destructor_zval, 1);
903903
zend_init_rsrc_list_dtors();
904904

905905
#ifdef ZTS

Zend/zend_compile.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1810,9 +1810,9 @@ ZEND_API void zend_initialize_class_data(zend_class_entry *ce, zend_bool nullify
18101810

18111811
ce->default_properties_table = NULL;
18121812
ce->default_static_members_table = NULL;
1813-
zend_hash_init_ex(&ce->properties_info, 8, NULL, (persistent_hashes ? zend_destroy_property_info_internal : NULL), persistent_hashes, 0);
1814-
zend_hash_init_ex(&ce->constants_table, 8, NULL, NULL, persistent_hashes, 0);
1815-
zend_hash_init_ex(&ce->function_table, 8, NULL, ZEND_FUNCTION_DTOR, persistent_hashes, 0);
1813+
zend_hash_init(&ce->properties_info, 8, NULL, (persistent_hashes ? zend_destroy_property_info_internal : NULL), persistent_hashes);
1814+
zend_hash_init(&ce->constants_table, 8, NULL, NULL, persistent_hashes);
1815+
zend_hash_init(&ce->function_table, 8, NULL, ZEND_FUNCTION_DTOR, persistent_hashes);
18161816

18171817
if (ce->type == ZEND_INTERNAL_CLASS) {
18181818
ZEND_MAP_PTR_INIT(ce->static_members_table, NULL);

Zend/zend_hash.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,6 @@ ZEND_API void ZEND_FASTCALL zend_hash_clean(HashTable *ht);
103103

104104
#define zend_hash_init(ht, nSize, pHashFunction, pDestructor, persistent) \
105105
_zend_hash_init((ht), (nSize), (pDestructor), (persistent))
106-
#define zend_hash_init_ex(ht, nSize, pHashFunction, pDestructor, persistent, bApplyProtection) \
107-
_zend_hash_init((ht), (nSize), (pDestructor), (persistent))
108106

109107
ZEND_API void ZEND_FASTCALL zend_hash_real_init(HashTable *ht, zend_bool packed);
110108
ZEND_API void ZEND_FASTCALL zend_hash_real_init_packed(HashTable *ht);

Zend/zend_ini.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ ZEND_API int zend_ini_startup(void) /* {{{ */
9696
EG(ini_directives) = registered_zend_ini_directives;
9797
EG(modified_ini_directives) = NULL;
9898
EG(error_reporting_ini_entry) = NULL;
99-
zend_hash_init_ex(registered_zend_ini_directives, 128, NULL, free_ini_entry, 1, 0);
99+
zend_hash_init(registered_zend_ini_directives, 128, NULL, free_ini_entry, 1);
100100
return SUCCESS;
101101
}
102102
/* }}} */
@@ -164,7 +164,7 @@ ZEND_API int zend_copy_ini_directives(void) /* {{{ */
164164
EG(modified_ini_directives) = NULL;
165165
EG(error_reporting_ini_entry) = NULL;
166166
EG(ini_directives) = (HashTable *) malloc(sizeof(HashTable));
167-
zend_hash_init_ex(EG(ini_directives), registered_zend_ini_directives->nNumOfElements, NULL, free_ini_entry, 1, 0);
167+
zend_hash_init(EG(ini_directives), registered_zend_ini_directives->nNumOfElements, NULL, free_ini_entry, 1);
168168
zend_hash_copy(EG(ini_directives), registered_zend_ini_directives, copy_ini_entry);
169169
return SUCCESS;
170170
}

Zend/zend_language_scanner.l

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ ZEND_API zend_ast *zend_compile_string_to_ast(
699699
zend_restore_lexical_state(&original_lex_state);
700700
CG(in_compilation) = original_in_compilation;
701701

702-
zval_dtor(&code_zv);
702+
zval_ptr_dtor_str(&code_zv);
703703

704704
return ast;
705705
}

Zend/zend_list.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ ZEND_API int zend_init_rsrc_list(void)
213213

214214
int zend_init_rsrc_plist(void)
215215
{
216-
zend_hash_init_ex(&EG(persistent_list), 8, NULL, plist_entry_destructor, 1, 0);
216+
zend_hash_init(&EG(persistent_list), 8, NULL, plist_entry_destructor, 1);
217217
return SUCCESS;
218218
}
219219

Zend/zend_ts_hash.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static void end_write(TsHashTable *ht)
5757
}
5858

5959
/* delegates */
60-
ZEND_API void _zend_ts_hash_init(TsHashTable *ht, uint32_t nSize, dtor_func_t pDestructor, zend_bool persistent)
60+
ZEND_API void zend_ts_hash_init(TsHashTable *ht, uint32_t nSize, dtor_func_t pDestructor, zend_bool persistent)
6161
{
6262
#ifdef ZTS
6363
ht->mx_reader = tsrm_mutex_alloc();

Zend/zend_ts_hash.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,10 @@ BEGIN_EXTERN_C()
3535
#define TS_HASH(table) (&(table->hash))
3636

3737
/* startup/shutdown */
38-
ZEND_API void _zend_ts_hash_init(TsHashTable *ht, uint32_t nSize, dtor_func_t pDestructor, zend_bool persistent);
38+
ZEND_API void zend_ts_hash_init(TsHashTable *ht, uint32_t nSize, dtor_func_t pDestructor, zend_bool persistent);
3939
ZEND_API void zend_ts_hash_destroy(TsHashTable *ht);
4040
ZEND_API void zend_ts_hash_clean(TsHashTable *ht);
4141

42-
#define zend_ts_hash_init(ht, nSize, pHashFunction, pDestructor, persistent) \
43-
_zend_ts_hash_init(ht, nSize, pDestructor, persistent)
44-
#define zend_ts_hash_init_ex(ht, nSize, pHashFunction, pDestructor, persistent, bApplyProtection) \
45-
_zend_ts_hash_init(ht, nSize, pDestructor, persistent)
46-
4742

4843
/* additions/updates/changes */
4944
ZEND_API zval *zend_ts_hash_update(TsHashTable *ht, zend_string *key, zval *pData);

Zend/zend_variables.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,6 @@ ZEND_API void zval_internal_ptr_dtor(zval *zvalue);
8181

8282
/* Kept for compatibility */
8383
#define zval_dtor(zvalue) zval_ptr_dtor_nogc(zvalue)
84-
#define zval_internal_dtor(zvalue) zval_internal_ptr_dtor(zvalue)
85-
#define zval_dtor_func rc_dtor_func
86-
#define zval_ptr_dtor_wrapper zval_ptr_dtor
87-
#define zval_internal_ptr_dtor_wrapper zval_internal_ptr_dtor
8884

8985
ZEND_API void zval_add_ref(zval *p);
9086

0 commit comments

Comments
 (0)