Skip to content

Commit 3932d9b

Browse files
committed
ext/libxml: Get rid of useless php_libxml_func_handler abstraction
1 parent dc03601 commit 3932d9b

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

ext/libxml/libxml.c

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ static bool php_libxml_initialized = false;
5353
static bool php_libxml_per_request_initialization = true;
5454
static xmlExternalEntityLoader php_libxml_default_entity_loader;
5555

56-
typedef struct php_libxml_func_handler {
57-
php_libxml_export_node export_func;
58-
} php_libxml_func_handler;
59-
6056
static HashTable php_libxml_exports;
6157

6258
static ZEND_DECLARE_MODULE_GLOBALS(libxml)
@@ -901,11 +897,6 @@ PHP_LIBXML_API void php_libxml_error_handler(void *ctx, const char *msg, ...)
901897
va_end(args);
902898
}
903899

904-
static void php_libxml_exports_dtor(zval *zv)
905-
{
906-
free(Z_PTR_P(zv));
907-
}
908-
909900
PHP_LIBXML_API void php_libxml_initialize(void)
910901
{
911902
if (!php_libxml_initialized) {
@@ -917,7 +908,7 @@ PHP_LIBXML_API void php_libxml_initialize(void)
917908
php_libxml_default_entity_loader = xmlGetExternalEntityLoader();
918909
xmlSetExternalEntityLoader(php_libxml_pre_ext_ent_loader);
919910

920-
zend_hash_init(&php_libxml_exports, 0, NULL, php_libxml_exports_dtor, 1);
911+
zend_hash_init(&php_libxml_exports, 0, NULL, NULL, 1);
921912

922913
php_libxml_initialized = true;
923914
}
@@ -1273,13 +1264,10 @@ bool php_libxml_xmlCheckUTF8(const unsigned char *s)
12731264

12741265
zval *php_libxml_register_export(const zend_class_entry *ce, php_libxml_export_node export_function)
12751266
{
1276-
php_libxml_func_handler export_hnd;
1277-
12781267
/* Initialize in case this module hasn't been loaded yet */
12791268
php_libxml_initialize();
1280-
export_hnd.export_func = export_function;
12811269

1282-
return zend_hash_add_mem(&php_libxml_exports, ce->name, &export_hnd, sizeof(export_hnd));
1270+
return zend_hash_add_ptr(&php_libxml_exports, ce->name, export_function);
12831271
}
12841272

12851273
PHP_LIBXML_API xmlNodePtr php_libxml_import_node(zval *object)
@@ -1291,9 +1279,9 @@ PHP_LIBXML_API xmlNodePtr php_libxml_import_node(zval *object)
12911279
while (ce->parent != NULL) {
12921280
ce = ce->parent;
12931281
}
1294-
const php_libxml_func_handler *export_hnd = zend_hash_find_ptr(&php_libxml_exports, ce->name);
1295-
if (export_hnd) {
1296-
node = export_hnd->export_func(object);
1282+
const php_libxml_export_node export_function = zend_hash_find_ptr(&php_libxml_exports, ce->name);
1283+
if (export_function) {
1284+
node = export_function(object);
12971285
}
12981286
}
12991287
return node;

0 commit comments

Comments
 (0)