当前仓库属于暂停状态,部分功能使用受限,详情请查阅 仓库状态说明
36 Star 80 Fork 17

Josin / CSpeed
暂停

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
cspeed.c 7.03 KB
一键复制 编辑 原始数据 按行查看 历史
liqiongfan 提交于 2018-05-13 16:20 . Fix the memoery leak
/*
+----------------------------------------------------------------------+
| CSpeed framework |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2017 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author:Josin<774542602@qq.com|www.supjos.cn> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "php_cspeed.h"
#include "kernel/tool/helper.h"
#include "kernel/di/di.h"
#include "kernel/mvc/router.h"
ZEND_DECLARE_MODULE_GLOBALS(cspeed)
/* True global resources - no need for thread safety here */
static int le_cspeed;
/* {{{ proto string getCSpeedVersion()
Return the CSpeed version */
PHP_FUNCTION(getCSpeedVersion)
{
RETURN_STRING(PHP_CSPEED_VERSION);
}
/* }}} */
/* {{{ PHP_MINIT_FUNCTION
*/
PHP_MINIT_FUNCTION(cspeed)
{
#if defined(COMPILE_DL_CSPEED) && defined(ZTS)
/* Allocate the memory for the system to use, only for ZTS */
ZEND_INIT_MODULE_GLOBALS(cspeed, NULL, NULL);
#endif
/* Initialise the all core class for the CSpeed engine */
/* Event support */
component_init();
/* The IOC object class */
object_factory_init();
/* Bootstrap interface */
bootinit_init();
/* Di|App|View */
di_init();
app_init();
view_init();
/* NOTE THAT: The model_interface_init() must before the adapter_init() method */
model_interface_init();
adapter_init();
/* Other init function */
request_init();
response_init();
controller_init();
/* ActiveRecord model */
model_init();
/* Config class */
config_init();
/* Router class */
router_init();
/* RPC class server */
server_init();
client_init();
/* CLI */
task_init();
/* After initialise, return SUCCESS means OK */
return SUCCESS;
}
/* }}} */
/* {{{ PHP_MSHUTDOWN_FUNCTION
*/
PHP_MSHUTDOWN_FUNCTION(cspeed)
{
return SUCCESS;
}
/* }}} */
/* Remove if there's nothing to do at request start */
/* {{{ PHP_RINIT_FUNCTION
*/
PHP_RINIT_FUNCTION(cspeed)
{
#if defined(COMPILE_DL_CSPEED) && defined(ZTS)
ZEND_TSRMLS_CACHE_UPDATE();
#endif
CSPEED_G(core_application) = zend_string_init(CSPEED_STRL(CORE_APPLICATION), 0);
CSPEED_G(core_bootstrap) = zend_string_init(CSPEED_STRL(CORE_BOOTSTRAP), 0);
CSPEED_G(core_router_default_module) = zend_string_init(CSPEED_STRL(CORE_ROUTER_DEFAULT_MODULE), 0);
CSPEED_G(core_router_default_controller) = zend_string_init(CSPEED_STRL(CORE_ROUTER_DEFAULT_CONTROLLER), 0);
CSPEED_G(core_router_default_action) = zend_string_init(CSPEED_STRL(CORE_ROUTER_DEFAULT_ACTION), 0);
CSPEED_G(core_view_ext) = zend_string_init(CSPEED_STRL(CORE_VIEW_EXT), 0);
CSPEED_G(core_view_auto_render) = CORE_VIEW_NEED_RENDER;
CSPEED_G(core_url_pattern) = zend_string_init(CSPEED_STRL(CORE_URL_PATTERN), 0);
CSPEED_G(core_debug_mode) = DEFAULT_CORE_DEBUG_MODE;
CSPEED_G(core_path_info_mode) = zend_string_init(CSPEED_STRL(DEFAULT_CORE_PATH_INFO_MODE), 0);
CSPEED_G(get_router_pattern) = zend_string_init(CSPEED_STRL(DEFAULT_GET_ROUTER_PATTERN), 0);
CSPEED_G(boot_class_name) = zend_string_init(CSPEED_STRL(CORE_BOOTSTRAP_CLASS_NAME), 0);
/* Initialise the Router object & Di object */
zval di_object, router_object;
object_init_ex(&di_object, cspeed_di_ce);
initialise_di_object_properties(&di_object);
object_init_ex(&router_object, cspeed_router_ce);
initialise_router_object_properties(&router_object);
CSPEED_G(di_object) = Z_OBJ(di_object);
CSPEED_G(router_object) = Z_OBJ(router_object);
/* Return the status */
return SUCCESS;
}
/* }}} */
/* Remove if there's nothing to do at request end */
/* {{{ PHP_RSHUTDOWN_FUNCTION
*/
PHP_RSHUTDOWN_FUNCTION(cspeed)
{
zend_string_release(CSPEED_G(core_application));
zend_string_release(CSPEED_G(core_bootstrap));
zend_string_release(CSPEED_G(core_router_default_module));
zend_string_release(CSPEED_G(core_router_default_controller));
zend_string_release(CSPEED_G(core_router_default_action));
zend_string_release(CSPEED_G(core_view_ext));
zend_string_release(CSPEED_G(core_url_pattern));
zend_string_release(CSPEED_G(get_router_pattern));
zend_string_release(CSPEED_G(core_path_info_mode));
zend_string_release(CSPEED_G(boot_class_name));
#if 0
pefree(CSPEED_G(di_object), 1);
pefree(CSPEED_G(router_object), 1);
#endif
/* free the memory, use this dtor instead of the pefree */
zend_object_std_dtor(CSPEED_G(di_object));
zend_object_std_dtor(CSPEED_G(router_object));
CSPEED_G(di_object) = NULL;
CSPEED_G(router_object) = NULL;
/* Return SUCCESS */
return SUCCESS;
}
/* }}} */
/* {{{ PHP_MINFO_FUNCTION
*/
PHP_MINFO_FUNCTION(cspeed)
{
php_info_print_table_start();
php_info_print_table_header(2, "CSpeed support", "enabled");
php_info_print_table_header(2, "Author", "Josin <774542602@qq.com|www.supjos.cn>");
php_info_print_table_header(2, "Version", PHP_CSPEED_VERSION);
php_info_print_table_end();
}
/* }}} */
/* {{{ cspeed_functions[]
*
* Every user visible function must have an entry in cspeed_functions[].
*/
const zend_function_entry cspeed_functions[] = {
PHP_FE(getCSpeedVersion, NULL) /* For testing, remove later. */
PHP_FE_END /* Must be the last line in cspeed_functions[] */
};
/* }}} */
/* {{{ cspeed_module_entry
*/
zend_module_entry cspeed_module_entry = {
STANDARD_MODULE_HEADER,
"cspeed",
cspeed_functions,
PHP_MINIT(cspeed),
PHP_MSHUTDOWN(cspeed),
PHP_RINIT(cspeed), /* Replace with NULL if there's nothing to do at request start */
PHP_RSHUTDOWN(cspeed), /* Replace with NULL if there's nothing to do at request end */
PHP_MINFO(cspeed),
PHP_CSPEED_VERSION,
STANDARD_MODULE_PROPERTIES
};
/* }}} */
#ifdef COMPILE_DL_CSPEED
#ifdef ZTS
ZEND_TSRMLS_CACHE_DEFINE()
#endif
ZEND_GET_MODULE(cspeed)
#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
*/
C
1
https://gitee.com/josinli/cspeed.git
git@gitee.com:josinli/cspeed.git
josinli
cspeed
CSpeed
master

搜索帮助