1 Star 0 Fork 2

LetuCRM/php-zephir-parser

forked from koogua/php-zephir-parser 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
zephir_parser.c 2.83 KB
一键复制 编辑 原始数据 按行查看 历史
朱宗鑫 提交于 2019-04-24 15:02 +08:00 . Fix memory leak
/* zephir_parser.c
*
* This file is part of the Zephir Parser.
*
* (c) Zephir Team <team@zephir-lang.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <php.h>
#include <php_ini.h>
#include <ext/standard/info.h>
#include "zephir_parser.h"
extern void *xx_parse_program(zval *return_value, char *program, size_t program_length, char *file_path, zval *error_msg);
/* {{{ proto array zephir_parse_file(string content, string filepath)
Parses a file and returning an intermediate array representation */
static PHP_FUNCTION(zephir_parse_file)
{
size_t filepath_len = 0;
size_t content_len = 0;
char *content = NULL;
char *filepath = NULL;
zval error_msg;
zval ret;
zval *e = &error_msg;
zval *r = &ret;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &content, &content_len, &filepath, &filepath_len) == FAILURE) {
RETURN_FALSE;
}
ZVAL_NULL(e);
ZVAL_NULL(r);
xx_parse_program(r, content, content_len, filepath, e);
if (Z_TYPE_P(e) == IS_ARRAY) {
zval_ptr_dtor(&ret);
RETURN_ZVAL(e, 0, 0);
}
assert(Z_TYPE_P(r) == IS_ARRAY);
zval_ptr_dtor(&error_msg);
RETURN_ZVAL(r, 1, 1);
}
/* }}} */
/* {{{ PHP_MINIT_FUNCTION
*/
PHP_MINIT_FUNCTION(zephir_parser)
{
return SUCCESS;
}
/* }}} */
/* {{{ PHP_MSHUTDOWN_FUNCTION
*/
PHP_MSHUTDOWN_FUNCTION(zephir_parser)
{
return SUCCESS;
}
/* }}} */
/* {{{ PHP_MINFO_FUNCTION
*/
PHP_MINFO_FUNCTION(zephir_parser)
{
php_info_print_box_start(0);
php_printf("%s", PHP_ZEPHIR_PARSER_DESCRIPTION);
php_info_print_box_end();
php_info_print_table_start();
php_info_print_table_header(2, PHP_ZEPHIR_PARSER_NAME, "enabled");
php_info_print_table_row(2, "Author", PHP_ZEPHIR_PARSER_AUTHOR);
php_info_print_table_row(2, "Version", PHP_ZEPHIR_PARSER_VERSION);
php_info_print_table_row(2, "Build Date", __DATE__ " " __TIME__);
php_info_print_table_end();
}
/* }}} */
/* {{{ zephir_parser_functions[]
*
* Every user visible function must have an entry in zephir_parser_functions[].
*/
static const zend_function_entry zephir_parser_functions[] = {
PHP_FE(zephir_parse_file, NULL)
PHP_FE_END
};
/* }}} */
/* {{{ zephir_parser_module_entry
*/
zend_module_entry zephir_parser_module_entry = {
STANDARD_MODULE_HEADER,
PHP_ZEPHIR_PARSER_NAME,
zephir_parser_functions,
PHP_MINIT(zephir_parser),
PHP_MSHUTDOWN(zephir_parser),
NULL,
NULL,
PHP_MINFO(zephir_parser),
PHP_ZEPHIR_PARSER_VERSION,
STANDARD_MODULE_PROPERTIES
};
/* }}} */
/* implement standard "stub" routine to introduce ourselves to Zend */
#ifdef COMPILE_DL_ZEPHIR_PARSER
# ifdef ZTS
ZEND_TSRMLS_CACHE_DEFINE()
# endif
ZEND_GET_MODULE(zephir_parser)
#endif
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/letucrm/php-zephir-parser.git
git@gitee.com:letucrm/php-zephir-parser.git
letucrm
php-zephir-parser
php-zephir-parser
master

搜索帮助