Skip to content

Commit b589d49

Browse files
committed
Move lexbor memory setup to ext/lexbor
1 parent 04991a6 commit b589d49

File tree

2 files changed

+29
-21
lines changed

2 files changed

+29
-21
lines changed

ext/dom/php_dom.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333
#include "dom_properties.h"
3434
#include "token_list.h"
3535
#include "zend_interfaces.h"
36-
#include <lexbor/core/types.h>
37-
#include <lexbor/core/lexbor.h>
3836

3937
#include "ext/standard/info.h"
4038

@@ -739,22 +737,6 @@ void dom_xpath_objects_free_storage(zend_object *object);
739737
HashTable *dom_xpath_get_gc(zend_object *object, zval **table, int *n);
740738
#endif
741739

742-
static void *dom_malloc(size_t size) {
743-
return emalloc(size);
744-
}
745-
746-
static void *dom_realloc(void *dst, size_t size) {
747-
return erealloc(dst, size);
748-
}
749-
750-
static void *dom_calloc(size_t num, size_t size) {
751-
return ecalloc(num, size);
752-
}
753-
754-
static void dom_free(void *ptr) {
755-
efree(ptr);
756-
}
757-
758740
/* {{{ PHP_MINIT_FUNCTION(dom) */
759741
PHP_MINIT_FUNCTION(dom)
760742
{
@@ -1325,8 +1307,6 @@ PHP_MINIT_FUNCTION(dom)
13251307
php_libxml_register_export(dom_node_class_entry, php_dom_export_node);
13261308
php_libxml_register_export(dom_modern_node_class_entry, php_dom_export_node);
13271309

1328-
lexbor_memory_setup(dom_malloc, dom_realloc, dom_calloc, dom_free);
1329-
13301310
return SUCCESS;
13311311
}
13321312
/* }}} */

ext/lexbor/php_lexbor.c

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include "php.h"
2323
#include "zend_globals.h"
2424
#include "ext/standard/info.h"
25+
#include "lexbor/core/types.h"
26+
#include "lexbor/core/lexbor.h"
2527

2628
#ifdef HAVE_LEXBOR
2729

@@ -35,6 +37,26 @@ ZEND_TSRMLS_CACHE_DEFINE()
3537
ZEND_GET_MODULE(lexbor)
3638
#endif /* COMPILE_DL_LEXBOR */
3739

40+
static void *php_lexbor_malloc(size_t size)
41+
{
42+
return emalloc(size);
43+
}
44+
45+
static void *php_lexbor_realloc(void *dst, size_t size)
46+
{
47+
return erealloc(dst, size);
48+
}
49+
50+
static void *php_lexbor_calloc(size_t num, size_t size)
51+
{
52+
return ecalloc(num, size);
53+
}
54+
55+
static void php_lexbor_free(void *ptr)
56+
{
57+
efree(ptr);
58+
}
59+
3860
static PHP_MINFO_FUNCTION(lexbor)
3961
{
4062
php_info_print_table_start();
@@ -43,11 +65,17 @@ static PHP_MINFO_FUNCTION(lexbor)
4365
php_info_print_table_end();
4466
}
4567

68+
static PHP_MINIT_FUNCTION(lexbor)
69+
{
70+
lexbor_memory_setup(php_lexbor_malloc, php_lexbor_realloc, php_lexbor_calloc, php_lexbor_free);
71+
return SUCCESS;
72+
}
73+
4674
zend_module_entry lexbor_module_entry = {
4775
STANDARD_MODULE_HEADER,
4876
"lexbor", /* extension name */
4977
NULL, /* extension function list */
50-
NULL, /* extension-wide startup function */
78+
PHP_MINIT(lexbor), /* extension-wide startup function */
5179
NULL, /* extension-wide shutdown function */
5280
NULL, /* per-request startup function */
5381
NULL, /* per-request shutdown function */

0 commit comments

Comments
 (0)