Coverage Report

Created: 2025-06-13 06:43

/src/php-src/ext/lexbor/php_lexbor.c
Line
Count
Source (jump to first uncovered line)
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/types.h"
26
#include "lexbor/core/lexbor.h"
27
28
#ifdef HAVE_LEXBOR
29
30
#include "php_lexbor.h"
31
32
static void *php_lexbor_malloc(size_t size)
33
900k
{
34
900k
  return emalloc(size);
35
900k
}
36
37
static void *php_lexbor_realloc(void *dst, size_t size)
38
0
{
39
0
  return erealloc(dst, size);
40
0
}
41
42
static void *php_lexbor_calloc(size_t num, size_t size)
43
2.40M
{
44
2.40M
  return ecalloc(num, size);
45
2.40M
}
46
47
static void php_lexbor_free(void *ptr)
48
3.30M
{
49
3.30M
  efree(ptr);
50
3.30M
}
51
52
static PHP_MINFO_FUNCTION(lexbor)
53
5
{
54
5
  php_info_print_table_start();
55
5
  php_info_print_table_row(2, "Lexbor support", "active");
56
5
  php_info_print_table_row(2, "Lexbor version", LEXBOR_VERSION);
57
5
  php_info_print_table_end();
58
5
}
59
60
static PHP_MINIT_FUNCTION(lexbor)
61
16
{
62
16
  lexbor_memory_setup(php_lexbor_malloc, php_lexbor_realloc, php_lexbor_calloc, php_lexbor_free);
63
16
  return SUCCESS;
64
16
}
65
66
zend_module_entry lexbor_module_entry = {
67
  STANDARD_MODULE_HEADER,
68
  "lexbor",                   /* extension name */
69
  NULL,                       /* extension function list */
70
  PHP_MINIT(lexbor),          /* extension-wide startup function */
71
  NULL,                       /* extension-wide shutdown function */
72
  NULL,                       /* per-request startup function */
73
  NULL,                       /* per-request shutdown function */
74
  PHP_MINFO(lexbor),          /* information function */
75
  NULL,
76
  STANDARD_MODULE_PROPERTIES
77
};
78
79
#endif