Browse Source

simplify sandbox/compiler_result code, removed alloc

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@935 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
3.0
Xuefer 10 years ago
parent
commit
397049014d
  1. 25
      utils.c
  2. 2
      utils.h

25
utils.c

@ -41,13 +41,7 @@ xc_compile_result_t *xc_compile_result_init(xc_compile_result_t *cr, /* {{{ */
HashTable *function_table,
HashTable *class_table)
{
if (cr) {
cr->alloc = 0;
}
else {
cr = emalloc(sizeof(xc_compile_result_t));
cr->alloc = 1;
}
assert(cr);
cr->op_array = op_array;
cr->function_table = function_table;
cr->class_table = class_table;
@ -56,14 +50,12 @@ xc_compile_result_t *xc_compile_result_init(xc_compile_result_t *cr, /* {{{ */
/* }}} */
xc_compile_result_t *xc_compile_result_init_cur(xc_compile_result_t *cr, zend_op_array *op_array TSRMLS_DC) /* {{{ */
{
assert(cr);
return xc_compile_result_init(cr, op_array, CG(function_table), CG(class_table));
}
/* }}} */
void xc_compile_result_free(xc_compile_result_t *cr) /* {{{ */
{
if (cr->alloc) {
efree(cr);
}
}
/* }}} */
@ -742,13 +734,8 @@ xc_sandbox_t *xc_sandbox_init(xc_sandbox_t *sandbox, ZEND_24(NOTHING, const) cha
{
HashTable *h;
if (sandbox) {
memset(sandbox, 0, sizeof(sandbox[0]));
}
else {
ECALLOC_ONE(sandbox);
sandbox->alloc = 1;
}
assert(sandbox);
memset(sandbox, 0, sizeof(sandbox[0]));
memcpy(&OG(included_files), &EG(included_files), sizeof(EG(included_files)));
@ -971,10 +958,6 @@ void xc_sandbox_free(xc_sandbox_t *sandbox, xc_install_action_t install TSRMLS_D
#ifdef ZEND_COMPILE_IGNORE_INTERNAL_CLASSES
CG(compiler_options) = sandbox->orig_compiler_options;
#endif
if (sandbox->alloc) {
efree(sandbox);
}
}
/* }}} */
int xc_vtrace(const char *fmt, va_list args) /* {{{ */

2
utils.h

@ -44,7 +44,6 @@ int xc_util_init(int module_number TSRMLS_DC);
void xc_util_destroy();
typedef struct {
int alloc;
zend_op_array *op_array;
HashTable *function_table;
HashTable *class_table;
@ -82,7 +81,6 @@ ZESW(xc_cest_t *, void) xc_install_class(ZEND_24(NOTHING, const) char *filename,
/* sandbox */
typedef struct {
int alloc;
ZEND_24(NOTHING, const) char *filename;
HashTable orig_included_files;

Loading…
Cancel
Save