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