/src/php-src/ext/lexbor/php_lexbor.c
Line | Count | Source |
1 | | /* |
2 | | +----------------------------------------------------------------------+ |
3 | | | Copyright © The PHP Group and Contributors. | |
4 | | +----------------------------------------------------------------------+ |
5 | | | This source file is subject to the Modified BSD License that is | |
6 | | | bundled with this package in the file LICENSE, and is available | |
7 | | | through the World Wide Web at <https://www.php.net/license/>. | |
8 | | | | |
9 | | | SPDX-License-Identifier: BSD-3-Clause | |
10 | | +----------------------------------------------------------------------+ |
11 | | | Authors: Niels Dossche <nielsdos@php.net> | |
12 | | | Mate Kocsis <kocsismate@php.net> | |
13 | | +----------------------------------------------------------------------+ |
14 | | */ |
15 | | |
16 | | #ifdef HAVE_CONFIG_H |
17 | | #include <config.h> |
18 | | #endif |
19 | | |
20 | | #include "php.h" |
21 | | #include "zend_globals.h" |
22 | | #include "ext/standard/info.h" |
23 | | #include "lexbor/core/base.h" |
24 | | #include "lexbor/core/types.h" |
25 | | #include "lexbor/core/lexbor.h" |
26 | | |
27 | | #ifdef HAVE_LEXBOR |
28 | | |
29 | | #include "php_lexbor.h" |
30 | | |
31 | | static void *php_lexbor_malloc(size_t size) |
32 | 914k | { |
33 | 914k | return emalloc(size); |
34 | 914k | } |
35 | | |
36 | | static void *php_lexbor_realloc(void *dst, size_t size) |
37 | 0 | { |
38 | 0 | return erealloc(dst, size); |
39 | 0 | } |
40 | | |
41 | | static void *php_lexbor_calloc(size_t num, size_t size) |
42 | 1.59M | { |
43 | 1.59M | return ecalloc(num, size); |
44 | 1.59M | } |
45 | | |
46 | | static void php_lexbor_free(void *ptr) |
47 | 2.51M | { |
48 | 2.51M | efree(ptr); |
49 | 2.51M | } |
50 | | |
51 | | static PHP_MINFO_FUNCTION(lexbor) |
52 | 4 | { |
53 | 4 | php_info_print_table_start(); |
54 | 4 | php_info_print_table_row(2, "Lexbor support", "active"); |
55 | 4 | php_info_print_table_row(2, "Lexbor version", LEXBOR_VERSION_STRING); |
56 | 4 | php_info_print_table_end(); |
57 | 4 | } |
58 | | |
59 | | static PHP_MINIT_FUNCTION(lexbor) |
60 | 16 | { |
61 | 16 | lexbor_memory_setup(php_lexbor_malloc, php_lexbor_realloc, php_lexbor_calloc, php_lexbor_free); |
62 | 16 | return SUCCESS; |
63 | 16 | } |
64 | | |
65 | | zend_module_entry lexbor_module_entry = { |
66 | | STANDARD_MODULE_HEADER, |
67 | | "lexbor", /* extension name */ |
68 | | NULL, /* extension function list */ |
69 | | PHP_MINIT(lexbor), /* extension-wide startup function */ |
70 | | NULL, /* extension-wide shutdown function */ |
71 | | NULL, /* per-request startup function */ |
72 | | NULL, /* per-request shutdown function */ |
73 | | PHP_MINFO(lexbor), /* information function */ |
74 | | PHP_VERSION, |
75 | | STANDARD_MODULE_PROPERTIES |
76 | | }; |
77 | | |
78 | | #endif |