这篇教程C++ EG函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中EG函数的典型用法代码示例。如果您正苦于以下问题:C++ EG函数的具体用法?C++ EG怎么用?C++ EG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了EG函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: process_stream_onReadstatic int process_stream_onRead(swReactor *reactor, swEvent *event){ SWOOLE_GET_TSRMLS; process_stream *ps = event->socket->object; char *buf = ps->buffer->str + ps->buffer->length; size_t len = ps->buffer->size - ps->buffer->length; int ret = read(event->fd, buf, len); if (ret > 0) { ps->buffer->length += ret; if (ps->buffer->length == ps->buffer->size) { swString_extend(ps->buffer, ps->buffer->size * 2); } return SW_OK; } else if (ret < 0) { swSysError("read() failed."); return SW_OK; } zval *retval = NULL; zval **args[2]; zval *zdata; SW_MAKE_STD_ZVAL(zdata); SW_ZVAL_STRINGL(zdata, ps->buffer->str, ps->buffer->length, 1); SwooleG.main_reactor->del(SwooleG.main_reactor, ps->fd); swString_free(ps->buffer); args[0] = &zdata; int status; zval *zstatus; SW_MAKE_STD_ZVAL(zstatus); pid_t pid = swWaitpid(ps->pid, &status, WNOHANG); if (pid > 0) { array_init(zstatus); add_assoc_long(zstatus, "code", WEXITSTATUS(status)); add_assoc_long(zstatus, "signal", WTERMSIG(status)); } else { ZVAL_FALSE(zstatus); } args[1] = &zstatus; zval *zcallback = ps->callback; if (zcallback) { if (sw_call_user_function_ex(EG(function_table), NULL, zcallback, &retval, 2, args, 0, NULL TSRMLS_CC) == FAILURE) { swoole_php_fatal_error(E_WARNING, "swoole_async: onAsyncComplete handler error"); } sw_zval_free(zcallback); } else {#ifdef SW_COROUTINE php_context *context = ps->context; sw_zval_add_ref(&zdata); add_assoc_zval(zstatus, "output", zdata); int ret = coro_resume(context, zstatus, &retval); if (ret == CORO_END && retval) { sw_zval_ptr_dtor(&retval); } efree(context);#else return SW_OK;#endif } if (EG(exception)) { zend_exception_error(EG(exception), E_ERROR TSRMLS_CC); } if (retval != NULL) { sw_zval_ptr_dtor(&retval); } sw_zval_ptr_dtor(&zdata); sw_zval_ptr_dtor(&zstatus); close(ps->fd); efree(ps); return SW_OK;}
开发者ID:leoozhao,项目名称:swoole-src,代码行数:96,
示例2: zend_build_cfgint zend_build_cfg(zend_arena **arena, const zend_op_array *op_array, uint32_t build_flags, zend_cfg *cfg, uint32_t *func_flags) /* {{{ */{ uint32_t flags = 0; uint32_t i; int j; uint32_t *block_map; zend_function *fn; int blocks_count = 0; zend_basic_block *blocks; zval *zv; cfg->map = block_map = zend_arena_calloc(arena, op_array->last, sizeof(uint32_t)); if (!block_map) { return FAILURE; } /* Build CFG, Step 1: Find basic blocks starts, calculate number of blocks */ BB_START(0); for (i = 0; i < op_array->last; i++) { zend_op *opline = op_array->opcodes + i; switch(opline->opcode) { case ZEND_RETURN: case ZEND_RETURN_BY_REF: case ZEND_GENERATOR_RETURN: case ZEND_EXIT: case ZEND_THROW: if (i + 1 < op_array->last) { BB_START(i + 1); } break; case ZEND_INCLUDE_OR_EVAL: flags |= ZEND_FUNC_INDIRECT_VAR_ACCESS; case ZEND_YIELD: case ZEND_YIELD_FROM: if (build_flags & ZEND_CFG_STACKLESS) { BB_START(i + 1); } break; case ZEND_DO_FCALL: case ZEND_DO_UCALL: case ZEND_DO_FCALL_BY_NAME: flags |= ZEND_FUNC_HAS_CALLS; if (build_flags & ZEND_CFG_STACKLESS) { BB_START(i + 1); } break; case ZEND_DO_ICALL: flags |= ZEND_FUNC_HAS_CALLS; break; case ZEND_INIT_FCALL: case ZEND_INIT_NS_FCALL_BY_NAME: zv = CRT_CONSTANT(opline->op2); if (opline->opcode == ZEND_INIT_NS_FCALL_BY_NAME) { /* The third literal is the lowercased unqualified name */ zv += 2; } if ((fn = zend_hash_find_ptr(EG(function_table), Z_STR_P(zv))) != NULL) { if (fn->type == ZEND_INTERNAL_FUNCTION) { if (zend_string_equals_literal(Z_STR_P(zv), "extract")) { flags |= ZEND_FUNC_INDIRECT_VAR_ACCESS; } else if (zend_string_equals_literal(Z_STR_P(zv), "compact")) { flags |= ZEND_FUNC_INDIRECT_VAR_ACCESS; } else if (zend_string_equals_literal(Z_STR_P(zv), "parse_str") && opline->extended_value == 1) { flags |= ZEND_FUNC_INDIRECT_VAR_ACCESS; } else if (zend_string_equals_literal(Z_STR_P(zv), "mb_parse_str") && opline->extended_value == 1) { flags |= ZEND_FUNC_INDIRECT_VAR_ACCESS; } else if (zend_string_equals_literal(Z_STR_P(zv), "get_defined_vars")) { flags |= ZEND_FUNC_INDIRECT_VAR_ACCESS; } else if (zend_string_equals_literal(Z_STR_P(zv), "func_num_args")) { flags |= ZEND_FUNC_VARARG; } else if (zend_string_equals_literal(Z_STR_P(zv), "func_get_arg")) { flags |= ZEND_FUNC_VARARG; } else if (zend_string_equals_literal(Z_STR_P(zv), "func_get_args")) { flags |= ZEND_FUNC_VARARG; } } } break; case ZEND_FAST_CALL: BB_START(OP_JMP_ADDR(opline, opline->op1) - op_array->opcodes); BB_START(i + 1); break; case ZEND_FAST_RET: if (i + 1 < op_array->last) { BB_START(i + 1); } break; case ZEND_JMP: BB_START(OP_JMP_ADDR(opline, opline->op1) - op_array->opcodes); if (i + 1 < op_array->last) { BB_START(i + 1); } break; case ZEND_JMPZNZ: BB_START(OP_JMP_ADDR(opline, opline->op2) - op_array->opcodes); BB_START(ZEND_OFFSET_TO_OPLINE_NUM(op_array, opline, opline->extended_value)); if (i + 1 < op_array->last) { BB_START(i + 1);//.........这里部分代码省略.........
开发者ID:CooCoooo,项目名称:php-src,代码行数:101,
示例3: executor_globals_ctorstatic void executor_globals_ctor(zend_executor_globals *executor_globals) /* {{{ */{ ZEND_TSRMLS_CACHE_UPDATE; zend_startup_constants(); zend_copy_constants(EG(zend_constants), GLOBAL_CONSTANTS_TABLE); zend_init_rsrc_plist(); zend_init_exception_op(); EG(lambda_count) = 0; ZVAL_UNDEF(&EG(user_error_handler)); ZVAL_UNDEF(&EG(user_exception_handler)); EG(in_autoload) = NULL; EG(current_execute_data) = NULL; EG(current_module) = NULL; EG(exit_status) = 0;#if XPFPA_HAVE_CW EG(saved_fpu_cw) = 0;#endif EG(saved_fpu_cw_ptr) = NULL; EG(active) = 0;}
开发者ID:ahamid,项目名称:php-src,代码行数:20,
示例4: init_executorvoid init_executor(void) /* {{{ */{ zend_init_fpu(); ZVAL_NULL(&EG(uninitialized_zval)); ZVAL_NULL(&EG(error_zval));/* destroys stack frame, therefore makes core dumps worthless */#if 0&&ZEND_DEBUG original_sigsegv_handler = signal(SIGSEGV, zend_handle_sigsegv);#endif EG(symtable_cache_ptr) = EG(symtable_cache) - 1; EG(symtable_cache_limit) = EG(symtable_cache) + SYMTABLE_CACHE_SIZE - 1; EG(no_extensions) = 0; EG(function_table) = CG(function_table); EG(class_table) = CG(class_table); EG(in_autoload) = NULL; EG(autoload_func) = NULL; EG(error_handling) = EH_NORMAL; zend_vm_stack_init(); zend_hash_init(&EG(symbol_table), 64, NULL, ZVAL_PTR_DTOR, 0); EG(valid_symbol_table) = 1; zend_llist_apply(&zend_extensions, (llist_apply_func_t) zend_extension_activator); zend_hash_init(&EG(included_files), 8, NULL, NULL, 0); EG(ticks_count) = 0; ZVAL_UNDEF(&EG(user_error_handler)); EG(current_execute_data) = NULL; zend_stack_init(&EG(user_error_handlers_error_reporting), sizeof(int)); zend_stack_init(&EG(user_error_handlers), sizeof(zval)); zend_stack_init(&EG(user_exception_handlers), sizeof(zval)); zend_objects_store_init(&EG(objects_store), 1024); EG(full_tables_cleanup) = 0;#ifdef ZEND_WIN32 EG(timed_out) = 0;#endif EG(exception) = NULL; EG(prev_exception) = NULL; EG(scope) = NULL; EG(ht_iterators_count) = sizeof(EG(ht_iterators_slots)) / sizeof(HashTableIterator); EG(ht_iterators_used) = 0; EG(ht_iterators) = EG(ht_iterators_slots); memset(EG(ht_iterators), 0, sizeof(EG(ht_iterators_slots))); EG(active) = 1;}
开发者ID:ante3,项目名称:php-src,代码行数:60,
示例5: zend_accel_load_scriptzend_op_array* zend_accel_load_script(zend_persistent_script *persistent_script, int from_shared_memory){ zend_op_array *op_array; op_array = (zend_op_array *) emalloc(sizeof(zend_op_array)); *op_array = persistent_script->main_op_array; if (EXPECTED(from_shared_memory)) { zend_hash_init(&ZCG(bind_hash), 10, NULL, NULL, 0); ZCG(current_persistent_script) = persistent_script; ZCG(arena_mem) = NULL; if (EXPECTED(persistent_script->arena_size)) {#ifdef __SSE2__ /* Target address must be aligned to 64-byte boundary */ ZCG(arena_mem) = zend_arena_alloc(&CG(arena), persistent_script->arena_size + 64); ZCG(arena_mem) = (void*)(((zend_uintptr_t)ZCG(arena_mem) + 63L) & ~63L); fast_memcpy(ZCG(arena_mem), persistent_script->arena_mem, persistent_script->arena_size);#else ZCG(arena_mem) = zend_arena_alloc(&CG(arena), persistent_script->arena_size); memcpy(ZCG(arena_mem), persistent_script->arena_mem, persistent_script->arena_size);#endif } /* Copy all the necessary stuff from shared memory to regular memory, and protect the shared script */ if (zend_hash_num_elements(&persistent_script->class_table) > 0) { zend_accel_class_hash_copy(CG(class_table), &persistent_script->class_table, (unique_copy_ctor_func_t) zend_class_copy_ctor); } /* we must first to copy all classes and then prepare functions, since functions may try to bind classes - which depend on pre-bind class entries existent in the class table */ if (zend_hash_num_elements(&persistent_script->function_table) > 0) { zend_accel_function_hash_copy_from_shm(CG(function_table), &persistent_script->function_table); } /* Register __COMPILER_HALT_OFFSET__ constant */ if (persistent_script->compiler_halt_offset != 0 && persistent_script->full_path) { zend_string *name; char haltoff[] = "__COMPILER_HALT_OFFSET__"; name = zend_mangle_property_name(haltoff, sizeof(haltoff) - 1, persistent_script->full_path->val, persistent_script->full_path->len, 0); if (!zend_hash_exists(EG(zend_constants), name)) { zend_register_long_constant(name->val, name->len, persistent_script->compiler_halt_offset, CONST_CS, 0); } zend_string_release(name); } zend_hash_destroy(&ZCG(bind_hash)); ZCG(current_persistent_script) = NULL; } else /* if (!from_shared_memory) */ { if (zend_hash_num_elements(&persistent_script->function_table) > 0) { zend_accel_function_hash_copy(CG(function_table), &persistent_script->function_table); } if (zend_hash_num_elements(&persistent_script->class_table) > 0) { zend_accel_class_hash_copy(CG(class_table), &persistent_script->class_table, NULL); } } if (op_array->early_binding != (uint32_t)-1) { zend_string *orig_compiled_filename = CG(compiled_filename); CG(compiled_filename) = persistent_script->full_path; zend_do_delayed_early_binding(op_array); CG(compiled_filename) = orig_compiled_filename; } if (UNEXPECTED(!from_shared_memory)) { free_persistent_script(persistent_script, 0); /* free only hashes */ } return op_array;}
开发者ID:Jille,项目名称:php-src,代码行数:71,
示例6: spprintf/* {{{ timezone_convert_to_datetimezone * Convert from TimeZone to DateTimeZone object */U_CFUNC zval *timezone_convert_to_datetimezone(const TimeZone *timeZone, intl_error *outside_error, const char *func, zval *ret){ UnicodeString id; char *message = NULL; php_timezone_obj *tzobj; zval arg; timeZone->getID(id); if (id.isBogus()) { spprintf(&message, 0, "%s: could not obtain TimeZone id", func); intl_errors_set(outside_error, U_ILLEGAL_ARGUMENT_ERROR, message, 1); goto error; } object_init_ex(ret, php_date_get_timezone_ce()); tzobj = Z_PHPTIMEZONE_P(ret); if (id.compare(0, 3, UnicodeString("GMT", sizeof("GMT")-1, US_INV)) == 0) { /* The DateTimeZone constructor doesn't support offset time zones, * so we must mess with DateTimeZone structure ourselves */ tzobj->initialized = 1; tzobj->type = TIMELIB_ZONETYPE_OFFSET; //convert offset from milliseconds to minutes tzobj->tzi.utc_offset = -1 * timeZone->getRawOffset() / (60 * 1000); } else { char *str; size_t str_len; /* Call the constructor! */ if (intl_charFromString(id, &str, &str_len, &INTL_ERROR_CODE(*outside_error)) == FAILURE) { spprintf(&message, 0, "%s: could not convert id to UTF-8", func); intl_errors_set(outside_error, INTL_ERROR_CODE(*outside_error), message, 1); goto error; } ZVAL_STRINGL(&arg, str, str_len); //??? efree(str); zend_call_method_with_1_params(ret, NULL, NULL, "__construct", NULL, &arg); if (EG(exception)) { spprintf(&message, 0, "%s: DateTimeZone constructor threw exception", func); intl_errors_set(outside_error, U_ILLEGAL_ARGUMENT_ERROR, message, 1); zend_object_store_ctor_failed(Z_OBJ_P(ret)); zval_ptr_dtor(&arg); goto error; } zval_ptr_dtor(&arg); } if (0) {error: if (ret) { zval_ptr_dtor(ret); } ret = NULL; } if (message) { efree(message); } return ret;}
开发者ID:Tyrael,项目名称:php-src,代码行数:68,
示例7: zend_generator_closeZEND_API void zend_generator_close(zend_generator *generator, zend_bool finished_execution TSRMLS_DC) /* {{{ */{ if (generator->value) { zval_ptr_dtor(&generator->value); generator->value = NULL; } if (generator->key) { zval_ptr_dtor(&generator->key); generator->key = NULL; } if (generator->execute_data) { zend_execute_data *execute_data = generator->execute_data; zend_op_array *op_array = execute_data->op_array; if (!execute_data->symbol_table) { zend_free_compiled_variables(execute_data); } else { zend_clean_and_cache_symbol_table(execute_data->symbol_table TSRMLS_CC); } if (execute_data->current_this) { zval_ptr_dtor(&execute_data->current_this); } /* If the generator is closed before it can finish execution (reach * a return statement) we have to free loop variables manually, as * we don't know whether the SWITCH_FREE / FREE opcodes have run */ if (!finished_execution) { /* -1 required because we want the last run opcode, not the * next to-be-run one. */ zend_uint op_num = execute_data->opline - op_array->opcodes - 1; int i; for (i = 0; i < op_array->last_brk_cont; ++i) { zend_brk_cont_element *brk_cont = op_array->brk_cont_array + i; if (brk_cont->start < 0) { continue; } else if (brk_cont->start > op_num) { break; } else if (brk_cont->brk > op_num) { zend_op *brk_opline = op_array->opcodes + brk_cont->brk; switch (brk_opline->opcode) { case ZEND_SWITCH_FREE: { temp_variable *var = EX_TMP_VAR(execute_data, brk_opline->op1.var); zval_ptr_dtor(&var->var.ptr); } break; case ZEND_FREE: { temp_variable *var = EX_TMP_VAR(execute_data, brk_opline->op1.var); zval_dtor(&var->tmp_var); } break; } } } } /* Clear any backed up stack arguments */ if (generator->stack != EG(argument_stack)) { void **stack_frame = zend_vm_stack_frame_base(execute_data); while (generator->stack->top != stack_frame) { zval_ptr_dtor((zval**)stack_frame); stack_frame++; } } while (execute_data->call >= execute_data->call_slots) { if (execute_data->call->object) { zval_ptr_dtor(&execute_data->call->object); } execute_data->call--; } /* We have added an additional stack frame in prev_execute_data, so we * have to free it. It also contains the arguments passed to the * generator (for func_get_args) so those have to be freed too. */ { zend_execute_data *prev_execute_data = execute_data->prev_execute_data; void **arguments = prev_execute_data->function_state.arguments; if (arguments) { int arguments_count = (int) (zend_uintptr_t) *arguments; zval **arguments_start = (zval **) (arguments - arguments_count); int i; for (i = 0; i < arguments_count; ++i) { zval_ptr_dtor(arguments_start + i); } } } /* Free a clone of closure */ if (op_array->fn_flags & ZEND_ACC_CLOSURE) { destroy_op_array(op_array TSRMLS_CC);//.........这里部分代码省略.........
开发者ID:Elik,项目名称:php-src,代码行数:101,
示例8: zephir_is_callable_check_classstatic int zephir_is_callable_check_class(const char *name, int name_len, zend_fcall_info_cache *fcc, int *strict_class, char **error) /* {{{ */{ int ret = 0; zend_class_entry *pce; zend_class_entry *scope, *called_scope; char *lcname = zend_str_tolower_dup(name, name_len);#if PHP_VERSION_ID >= 70100 scope = EG(fake_scope); called_scope = zend_get_called_scope(EG(current_execute_data));#else scope = EG(scope); called_scope = EG(current_execute_data)->called_scope;#endif *strict_class = 0; if (name_len == sizeof("self") - 1 && !memcmp(lcname, "self", sizeof("self") - 1)) { if (!scope) { if (error) *error = estrdup("cannot access self:: when no class scope is active"); } else { fcc->called_scope = called_scope; if (!fcc->object) { fcc->object = Z_OBJ(EG(current_execute_data)->This); } ret = 1; } } else if (name_len == sizeof("parent") - 1 && !memcmp(lcname, "parent", sizeof("parent") - 1)) { if (!scope) { if (error) *error = estrdup("cannot access parent:: when no class scope is active"); } else if (!scope->parent) { if (error) *error = estrdup("cannot access parent:: when current class scope has no parent"); } else { fcc->called_scope = called_scope; if (!fcc->object) { fcc->object = Z_OBJ(EG(current_execute_data)->This); } *strict_class = 1; ret = 1; } } else if (name_len == sizeof("static") - 1 && !memcmp(lcname, "static", sizeof("static") - 1)) { if (!called_scope) { if (error) *error = estrdup("cannot access static:: when no class scope is active"); } else { fcc->called_scope = called_scope; if (!fcc->object) { fcc->object = Z_OBJ(EG(current_execute_data)->This); } *strict_class = 1; ret = 1; } } else { zend_string *class_name; class_name = zend_string_init(name, name_len, 0); if ((pce = zend_lookup_class_ex(class_name, NULL, 1)) != NULL) { scope = EG(current_execute_data) ? EG(current_execute_data)->func->common.scope : NULL; fcc->calling_scope = pce; if (scope && !fcc->object && EG(current_execute_data) && Z_OBJ(EG(current_execute_data)->This) && instanceof_function(Z_OBJCE(EG(current_execute_data)->This), scope TSRMLS_CC) && instanceof_function(scope, fcc->calling_scope TSRMLS_CC)) { fcc->object = Z_OBJ(EG(current_execute_data)->This); fcc->called_scope = fcc->object->ce; } else { fcc->called_scope = fcc->object ? fcc->object->ce : fcc->calling_scope; } *strict_class = 1; ret = 1; } else { if (error) zephir_spprintf(error, 0, "class '%.*s' not found", name_len, name); } zend_string_free(class_name); } efree(lcname); return ret;}
开发者ID:phalcongelist,项目名称:beanspeak,代码行数:75,
示例9: zephir_call_func_aparams_fastint zephir_call_func_aparams_fast(zval *return_value_ptr, zephir_fcall_cache_entry **cache_entry, zend_uint param_count, zval *params[]){ uint32_t i; zend_class_entry *calling_scope = NULL; zend_execute_data *call, dummy_execute_data; zval retval_local; zval *retval_ptr = return_value_ptr ? return_value_ptr : &retval_local; zend_class_entry *orig_scope; zend_function *func; if (return_value_ptr) { zval_ptr_dtor(return_value_ptr); ZVAL_UNDEF(return_value_ptr); } else { ZVAL_UNDEF(&retval_local); } if (!EG(active)) { return FAILURE; /* executor is already inactive */ } if (EG(exception)) { return FAILURE; /* we would result in an instable executor otherwise */ }#if PHP_VERSION_ID >= 70100 orig_scope = EG(fake_scope);#else orig_scope = EG(scope);#endif /* Initialize execute_data */ if (!EG(current_execute_data)) { /* This only happens when we're called outside any execute()'s * It shouldn't be strictly necessary to NULL execute_data out, * but it may make bugs easier to spot */ memset(&dummy_execute_data, 0, sizeof(zend_execute_data)); EG(current_execute_data) = &dummy_execute_data; } else if (EG(current_execute_data)->func && ZEND_USER_CODE(EG(current_execute_data)->func->common.type) && EG(current_execute_data)->opline->opcode != ZEND_DO_FCALL && EG(current_execute_data)->opline->opcode != ZEND_DO_ICALL && EG(current_execute_data)->opline->opcode != ZEND_DO_UCALL && EG(current_execute_data)->opline->opcode != ZEND_DO_FCALL_BY_NAME) { /* Insert fake frame in case of include or magic calls */ dummy_execute_data = *EG(current_execute_data); dummy_execute_data.prev_execute_data = EG(current_execute_data); dummy_execute_data.call = NULL; dummy_execute_data.opline = NULL; dummy_execute_data.func = NULL; EG(current_execute_data) = &dummy_execute_data; }#ifndef ZEPHIR_RELEASE func = (*cache_entry)->f; ++(*cache_entry)->times;#else func = *cache_entry;#endif calling_scope = NULL; call = zend_vm_stack_push_call_frame(ZEND_CALL_TOP_FUNCTION, func, param_count, NULL, NULL); for (i = 0; i < param_count; i++) { zval *param; zval *arg = params[i]; if (ARG_SHOULD_BE_SENT_BY_REF(func, i + 1)) { if (!Z_ISREF_P(arg)) { /*if (!ARG_MAY_BE_SENT_BY_REF(func, i + 1)) { if (i) { // hack to clean up the stack ZEND_CALL_NUM_ARGS(call) = i; zend_vm_stack_free_args(call); } zend_vm_stack_free_call_frame(call); zend_error(E_WARNING, "Parameter %d to %s%s%s() expected to be a reference, value given", i+1, func->common.scope ? ZSTR_VAL(func->common.scope->name) : "", func->common.scope ? "::" : "", ZSTR_VAL(func->common.function_name)); if (EG(current_execute_data) == &dummy_execute_data) { EG(current_execute_data) = dummy_execute_data.prev_execute_data; } return FAILURE; }*/ ZVAL_NEW_REF(arg, arg); } Z_ADDREF_P(arg); } else { if (Z_ISREF_P(arg) && !(func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE)) { /* don't separate references for __call */ arg = Z_REFVAL_P(arg); } if (Z_OPT_REFCOUNTED_P(arg)) { Z_ADDREF_P(arg);//.........这里部分代码省略.........
开发者ID:phalcongelist,项目名称:beanspeak,代码行数:101,
示例10: _php_mb_regex_ereg_replace_exec//.........这里部分代码省略......... i += fwd; } } } if (eval) { zval v; zend_string *eval_str; /* null terminate buffer */ smart_str_0(&eval_buf); if (eval_buf.s) { eval_str = eval_buf.s; } else { eval_str = ZSTR_EMPTY_ALLOC(); } /* do eval */ if (zend_eval_stringl(ZSTR_VAL(eval_str), ZSTR_LEN(eval_str), &v, description) == FAILURE) { efree(description); zend_throw_error(NULL, "Failed evaluating code: %s%s", PHP_EOL, ZSTR_VAL(eval_str)); onig_region_free(regs, 0); smart_str_free(&out_buf); smart_str_free(&eval_buf); RETURN_FALSE; } /* result of eval */ convert_to_string(&v); smart_str_appendl(&out_buf, Z_STRVAL(v), Z_STRLEN(v)); /* Clean up */ smart_str_free(&eval_buf); zval_dtor(&v); } else if (is_callable) { zval args[1]; zval subpats, retval; int i; array_init(&subpats); for (i = 0; i < regs->num_regs; i++) { add_next_index_stringl(&subpats, string + regs->beg[i], regs->end[i] - regs->beg[i]); } ZVAL_COPY_VALUE(&args[0], &subpats); /* null terminate buffer */ smart_str_0(&eval_buf); arg_replace_fci.param_count = 1; arg_replace_fci.params = args; arg_replace_fci.retval = &retval; if (zend_call_function(&arg_replace_fci, &arg_replace_fci_cache) == SUCCESS && !Z_ISUNDEF(retval)) { convert_to_string_ex(&retval); smart_str_appendl(&out_buf, Z_STRVAL(retval), Z_STRLEN(retval)); smart_str_free(&eval_buf); zval_ptr_dtor(&retval); } else { if (!EG(exception)) { php_error_docref(NULL, E_WARNING, "Unable to call custom replacement function"); } } zval_ptr_dtor(&subpats); } n = regs->end[0]; if ((pos - (OnigUChar *)string) < n) { pos = (OnigUChar *)string + n; } else { if (pos < string_lim) { smart_str_appendl(&out_buf, (char *)pos, 1); } pos++; } } else { /* nomatch */ /* stick that last bit of string on our output */ if (string_lim - pos > 0) { smart_str_appendl(&out_buf, (char *)pos, string_lim - pos); } } onig_region_free(regs, 0); } if (description) { efree(description); } if (regs != NULL) { onig_region_free(regs, 1); } smart_str_free(&eval_buf); if (err <= -2) { smart_str_free(&out_buf); RETVAL_FALSE; } else if (out_buf.s) { smart_str_0(&out_buf); RETVAL_STR(out_buf.s); } else { RETVAL_EMPTY_STRING(); }}
开发者ID:JackDr3am,项目名称:php-src,代码行数:101,
示例11: zend_hash_next_free_element{ int index; zval zv; index = zend_hash_next_free_element(&EG(regular_list)); if (index == 0) { index = 1; } ZVAL_NEW_RES(&zv, index, ptr, type); return zend_hash_index_add_new(&EG(regular_list), index, &zv);}ZEND_API int _zend_list_delete(zend_resource *res TSRMLS_DC){ if (--GC_REFCOUNT(res) <= 0) { return zend_hash_index_del(&EG(regular_list), res->handle); } else { return SUCCESS; }}ZEND_API int _zend_list_free(zend_resource *res TSRMLS_DC){ if (GC_REFCOUNT(res) <= 0) { return zend_hash_index_del(&EG(regular_list), res->handle); } else { return SUCCESS; }}static void zend_resource_dtor(zend_resource *res TSRMLS_DC)
开发者ID:0x1111,项目名称:php-src,代码行数:31,
示例12: php_var_dumpPHPAPI void php_var_dump(zval *struc, int level) /* {{{ */{ HashTable *myht; zend_string *class_name; int is_temp; int is_ref = 0; zend_ulong num; zend_string *key; zval *val; if (level > 1) { php_printf("%*c", level - 1, ' '); }again: switch (Z_TYPE_P(struc)) { case IS_FALSE: php_printf("%sbool(false)/n", COMMON); break; case IS_TRUE: php_printf("%sbool(true)/n", COMMON); break; case IS_NULL: php_printf("%sNULL/n", COMMON); break; case IS_LONG: php_printf("%sint(" ZEND_LONG_FMT ")/n", COMMON, Z_LVAL_P(struc)); break; case IS_DOUBLE: php_printf("%sfloat(%.*G)/n", COMMON, (int) EG(precision), Z_DVAL_P(struc)); break; case IS_STRING: php_printf("%sstring(%d) /"", COMMON, Z_STRLEN_P(struc)); PHPWRITE(Z_STRVAL_P(struc), Z_STRLEN_P(struc)); PUTS("/"/n"); break; case IS_ARRAY: myht = Z_ARRVAL_P(struc); if (level > 1 && ZEND_HASH_APPLY_PROTECTION(myht) && ++myht->u.v.nApplyCount > 1) { PUTS("*RECURSION*/n"); --myht->u.v.nApplyCount; return; } php_printf("%sarray(%d) {/n", COMMON, zend_hash_num_elements(myht)); is_temp = 0; ZEND_HASH_FOREACH_KEY_VAL_IND(myht, num, key, val) { php_array_element_dump(val, num, key, level); } ZEND_HASH_FOREACH_END(); if (level > 1 && ZEND_HASH_APPLY_PROTECTION(myht)) { --myht->u.v.nApplyCount; } if (is_temp) { zend_hash_destroy(myht); efree(myht); } if (level > 1) { php_printf("%*c", level-1, ' '); } PUTS("}/n"); break; case IS_OBJECT: if (Z_OBJ_APPLY_COUNT_P(struc) > 0) { PUTS("*RECURSION*/n"); return; } Z_OBJ_INC_APPLY_COUNT_P(struc); myht = Z_OBJDEBUG_P(struc, is_temp); class_name = Z_OBJ_HANDLER_P(struc, get_class_name)(Z_OBJ_P(struc)); php_printf("%sobject(%s)#%d (%d) {/n", COMMON, ZSTR_VAL(class_name), Z_OBJ_HANDLE_P(struc), myht ? zend_obj_num_elements(myht) : 0); zend_string_release(class_name); if (myht) { zend_ulong num; zend_string *key; zval *val; ZEND_HASH_FOREACH_KEY_VAL_IND(myht, num, key, val) { php_object_property_dump(val, num, key, level); } ZEND_HASH_FOREACH_END(); if (is_temp) { zend_hash_destroy(myht); efree(myht); } }
开发者ID:nicolas-grekas,项目名称:php-src,代码行数:86,
示例13: http_onReceivestatic int http_onReceive(swFactory *factory, swEventData *req){ TSRMLS_FETCH_FROM_CTX(sw_thread_ctx ? sw_thread_ctx : NULL); int fd = req->info.fd;// swTrace("on receive:%s pid:%d/n", zdata, getpid()); swConnection *conn = swServer_connection_get(SwooleG.serv, fd); if(conn->websocket_status == WEBSOCKET_STATUS_HANDSHAKE) //websocket callback { zval *zdata = php_swoole_get_data(req TSRMLS_CC); swTrace("on message callback/n"); char *buf = Z_STRVAL_P(zdata); long fin = buf[0] ? 1 : 0; long opcode = buf[1] ? 1 : 0; buf+=2; zval *zresponse; MAKE_STD_ZVAL(zresponse); object_init_ex(zresponse, swoole_http_wsresponse_class_entry_ptr); //socket fd zend_update_property_long(swoole_http_wsresponse_class_entry_ptr, zresponse, ZEND_STRL("fd"), fd TSRMLS_CC); zend_update_property_long(swoole_http_wsresponse_class_entry_ptr, zresponse, ZEND_STRL("fin"), fin TSRMLS_CC); zend_update_property_long(swoole_http_wsresponse_class_entry_ptr, zresponse, ZEND_STRL("opcode"), opcode TSRMLS_CC); zend_update_property_stringl(swoole_http_wsresponse_class_entry_ptr, zresponse, ZEND_STRL("data"), buf, (Z_STRLEN_P(zdata)-2) TSRMLS_CC); zval **args[1]; args[0] = &zresponse; zval *retval; if (call_user_function_ex(EG(function_table), NULL, php_sw_http_server_callbacks[1], &retval, 1, args, 0, NULL TSRMLS_CC) == FAILURE) { zval_ptr_dtor(&zdata); php_error_docref(NULL TSRMLS_CC, E_WARNING, "onMessage handler error"); } swTrace("===== message callback end======"); if (EG(exception)) { zval_ptr_dtor(&zdata); zend_exception_error(EG(exception), E_ERROR TSRMLS_CC); } if (retval) { zval_ptr_dtor(&retval); } zval_ptr_dtor(&zdata); return SW_OK; } http_client *client = swHashMap_find_int(php_sw_http_clients, fd); if (!client) { client = http_client_new(fd TSRMLS_CC); } php_http_parser *parser = &client->parser; /** * create request and response object */ http_request_new(client TSRMLS_CC); parser->data = client; php_http_parser_init(parser, PHP_HTTP_REQUEST); zval *zdata = php_swoole_get_data(req TSRMLS_CC); //server info zval *_request; MAKE_STD_ZVAL(_request); array_init(_request); zend_update_property(swoole_http_request_class_entry_ptr, client->zrequest, ZEND_STRL("request"), _request TSRMLS_CC); size_t n = php_http_parser_execute(parser, &http_parser_settings, Z_STRVAL_P(zdata), Z_STRLEN_P(zdata)); zval_ptr_dtor(&zdata); if (n < 0) { swWarn("php_http_parser_execute failed."); if(conn->websocket_status == WEBSOCKET_STATUS_CONNECTION) { SwooleG.serv->factory.end(&SwooleG.serv->factory, fd); } } else { if(conn->websocket_status == WEBSOCKET_STATUS_CONNECTION) // need handshake { if(php_sw_http_server_callbacks[2] == NULL) { int ret = websocket_handshake(client); http_request_free(client TSRMLS_CC); if (ret == SW_ERR) { swTrace("websocket handshake error/n"); SwooleG.serv->factory.end(&SwooleG.serv->factory, fd); } else { handshake_success(fd);//.........这里部分代码省略.........
开发者ID:solomylove,项目名称:swoole-src,代码行数:101,
示例14: php_swoole_aio_onComplete//.........这里部分代码省略.........#else zwriten = &_zwriten;#endif args[0] = &file_req->filename; args[1] = &zwriten; ZVAL_LONG(zwriten, ret); } else if(event->type == SW_AIO_GETHOSTBYNAME) { args[0] = &dns_req->domain;#if PHP_MAJOR_VERSION < 7 SW_MAKE_STD_ZVAL(zcontent);#else zcontent = &_zcontent;#endif if (ret < 0) { SW_ZVAL_STRING(zcontent, "", 1); } else { SW_ZVAL_STRING(zcontent, event->buf, 1); } args[1] = &zcontent; } else { swoole_php_fatal_error(E_WARNING, "swoole_async: onAsyncComplete unknown event type[%d].", event->type); return; } if (zcallback) { if (sw_call_user_function_ex(EG(function_table), NULL, zcallback, &retval, 2, args, 0, NULL TSRMLS_CC) == FAILURE) { swoole_php_fatal_error(E_WARNING, "swoole_async: onAsyncComplete handler error"); return; } if (EG(exception)) { zend_exception_error(EG(exception), E_ERROR TSRMLS_CC); } } //file io if (file_req) { if (file_req->once == 1) { close_file: close(event->fd); swHashMap_del_int(php_swoole_aio_request, event->task_id); } else if(file_req->type == SW_AIO_WRITE) { if (retval != NULL && !ZVAL_IS_NULL(retval) && !Z_BVAL_P(retval)) { swHashMap_del(php_swoole_open_files, Z_STRVAL_P(file_req->filename), Z_STRLEN_P(file_req->filename)); goto close_file; } else { swHashMap_del_int(php_swoole_aio_request, event->task_id); } } else
开发者ID:leoozhao,项目名称:swoole-src,代码行数:67,
示例15: MAKE_STD_ZVAL MAKE_STD_ZVAL(method_name); ZVAL_STRING(method_name,"autoload",1); Z_ADDREF_P(autoload); add_next_index_zval(autoload,loader); add_next_index_zval(autoload,method_name); MAKE_STD_ZVAL(function); ZVAL_STRING(function,"spl_autoload_register",0); zend_fcall_info fci = { sizeof(fci), EG(function_table), function, NULL, &ret, 1, (zval ***)params, NULL, 1 }; if(zend_call_function(&fci, NULL TSRMLS_CC) == FAILURE) { if(ret){ zval_ptr_dtor(&ret); } zval_ptr_dtor(&autoload); efree(function);
开发者ID:im286er,项目名称:FoolPHP,代码行数:30,
示例16: php_swoole_aio_onCompletestatic void php_swoole_aio_onComplete(swAio_event *event){ int isEOF = SW_FALSE; int64_t ret; zval *retval = NULL, *zcallback = NULL, *zwriten = NULL; zval *zcontent = NULL; zval **args[2]; swoole_async_file_request *file_req = NULL; swoole_async_dns_request *dns_req = NULL; TSRMLS_FETCH_FROM_CTX(sw_thread_ctx ? sw_thread_ctx : NULL); if (event->type == SW_AIO_DNS_LOOKUP) { dns_req = (swoole_async_dns_request *) event->req; if (dns_req->callback == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "swoole_async: onAsyncComplete callback not found[2]"); return; } zcallback = dns_req->callback; } else { if (zend_hash_find(&php_sw_aio_callback, (char *)&(event->fd), sizeof(event->fd), (void**) &file_req) != SUCCESS) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "swoole_async: onAsyncComplete callback not found[1]"); return; } if (file_req->callback == NULL && file_req->type == SW_AIO_READ) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "swoole_async: onAsyncComplete callback not found[2]"); return; } zcallback = file_req->callback; } ret = event->ret; if (ret < 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "swoole_async: Aio Error: %s[%d]", strerror(event->error), event->error); } else if (file_req != NULL) { if (ret == 0) { bzero(event->buf, event->nbytes); isEOF = SW_TRUE; } else if (file_req->once == 1 && ret < file_req->content_length) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "swoole_async: ret_length[%d] < req->length[%d].", (int) ret, file_req->content_length); } file_req->offset += event->ret; } if (event->type == SW_AIO_READ) { MAKE_STD_ZVAL(zcontent); args[0] = &file_req->filename; args[1] = &zcontent; ZVAL_STRINGL(zcontent, event->buf, ret, 0); } else if(event->type == SW_AIO_WRITE) { MAKE_STD_ZVAL(zwriten); args[0] = &file_req->filename; args[1] = &zwriten; ZVAL_LONG(zwriten, ret); } else if(event->type == SW_AIO_DNS_LOOKUP) { MAKE_STD_ZVAL(zcontent); args[0] = &dns_req->domain; if (ret < 0) { ZVAL_STRING(zcontent, "", 0); } else { ZVAL_STRING(zcontent, event->buf, 0); } args[1] = &zcontent; } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "swoole_async: onAsyncComplete unknow event type"); return; } if (zcallback) { if (call_user_function_ex(EG(function_table), NULL, zcallback, &retval, 2, args, 0, NULL TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "swoole_async: onAsyncComplete handler error"); return; } }//.........这里部分代码省略.........
开发者ID:huangdehui2013,项目名称:swoole-src,代码行数:101,
示例17: ZEND_CLOSURE_PROPERTY_ERRORstatic zval *zend_closure_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv) /* {{{ */{ ZEND_CLOSURE_PROPERTY_ERROR(); return &EG(uninitialized_zval);}
开发者ID:ChadSikorra,项目名称:php-src,代码行数:5,
示例18: PHP_METHODPHP_METHOD(DefaultCluster, connectAsync){ char* hash_key; int hash_key_len = 0; char* keyspace = NULL; int keyspace_len; cassandra_cluster* cluster = NULL; cassandra_future_session* future = NULL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &keyspace, &keyspace_len) == FAILURE) { return; } cluster = (cassandra_cluster*) zend_object_store_get_object(getThis() TSRMLS_CC); object_init_ex(return_value, cassandra_future_session_ce); future = (cassandra_future_session*) zend_object_store_get_object(return_value TSRMLS_CC); future->persist = cluster->persist; if (cluster->persist) { zend_rsrc_list_entry *le; hash_key_len = spprintf(&hash_key, 0, "%s:session:%s", cluster->hash_key, SAFE_STR(keyspace)); future->hash_key = hash_key; future->hash_key_len = hash_key_len; if (zend_hash_find(&EG(persistent_list), hash_key, hash_key_len + 1, (void **)&le) == SUCCESS) { if (Z_TYPE_P(le) == php_le_cassandra_session()) { cassandra_psession* psession = (cassandra_psession*) le->ptr; future->session = psession->session; future->future = psession->future; return; } } } future->session = cass_session_new(); if (keyspace) { future->future = cass_session_connect_keyspace(future->session, cluster->cluster, keyspace); } else { future->future = cass_session_connect(future->session, cluster->cluster); } if (cluster->persist) { zend_rsrc_list_entry le; cassandra_psession* psession = (cassandra_psession*) pecalloc(1, sizeof(cassandra_psession), 1); psession->session = future->session; psession->future = future->future; le.type = php_le_cassandra_session(); le.ptr = psession; zend_hash_update(&EG(persistent_list), hash_key, hash_key_len + 1, &le, sizeof(zend_rsrc_list_entry), NULL); CASSANDRA_G(persistent_sessions)++; }}
开发者ID:moarty,项目名称:php-driver,代码行数:61,
示例19: zend_init_fpu +----------------------------------------------------------------------+*//* $Id$ */#include "zend.h"#include "zend_compile.h"#include "zend_float.h"ZEND_API void zend_init_fpu(void) /* {{{ */{#if XPFPA_HAVE_CW XPFPA_DECLARE if (!EG(saved_fpu_cw_ptr)) { EG(saved_fpu_cw_ptr) = (void*)&EG(saved_fpu_cw); } XPFPA_STORE_CW(EG(saved_fpu_cw_ptr)); XPFPA_SWITCH_DOUBLE();#else EG(saved_fpu_cw_ptr) = NULL;#endif}/* }}} */ZEND_API void zend_shutdown_fpu(void) /* {{{ */{#if XPFPA_HAVE_CW if (EG(saved_fpu_cw_ptr)) { XPFPA_RESTORE_CW(EG(saved_fpu_cw_ptr)); }
开发者ID:AllenJB,项目名称:php-src,代码行数:31,
示例20: cli_mainstatic int cli_main( int argc, char * argv[] ){ static const char * ini_defaults[] = { "report_zend_debug", "0", "display_errors", "1", "register_argc_argv", "1", "html_errors", "0", "implicit_flush", "1", "output_buffering", "0", "max_execution_time", "0", "max_input_time", "-1", NULL }; const char ** ini; char ** p = &argv[1]; char ** argend= &argv[argc]; int ret = -1; int c; zend_string *psKey; lsapi_mode = 0; /* enter CLI mode */ zend_first_try { SG(server_context) = (void *) 1; zend_uv.html_errors = 0; /* tell the engine we're in non-html mode */ CG(in_compilation) = 0; /* not initialized but needed for several options */ SG(options) |= SAPI_OPTION_NO_CHDIR;#if PHP_MAJOR_VERSION < 7 EG(uninitialized_zval_ptr) = NULL;#endif for( ini = ini_defaults; *ini; ini+=2 ) { psKey = zend_string_init(*ini, strlen( *ini ), 1); zend_alter_ini_entry_chars(psKey, (char *)*(ini+1), strlen( *(ini+1) ), PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE); zend_string_release_ex(psKey, 1); } while (( p < argend )&&(**p == '-' )) { c = *((*p)+1); ++p; switch( c ) { case 'q': break; case 'i': if (php_request_startup() != FAILURE) { php_print_info(0xFFFFFFFF);#ifdef PHP_OUTPUT_NEWAPI php_output_end_all();#else php_end_ob_buffers(1);#endif php_request_shutdown( NULL ); ret = 0; } break; case 'v': if (php_request_startup() != FAILURE) {#if ZEND_DEBUG php_printf("PHP %s (%s) (built: %s %s) (DEBUG)/nCopyright (c) The PHP Group/n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());#else php_printf("PHP %s (%s) (built: %s %s)/nCopyright (c) The PHP Group/n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());#endif#ifdef PHP_OUTPUT_NEWAPI php_output_end_all();#else php_end_ob_buffers(1);#endif php_request_shutdown( NULL ); ret = 0; } break; case 'c': ++p; /* fall through */ case 's': break; case 'l': source_highlight = 2; break; case 'h': case '?': default: cli_usage(); ret = 0; break; } } if ( ret == -1 ) { if ( *p ) { zend_file_handle file_handle; memset(&file_handle, 0, sizeof(file_handle)); file_handle.type = ZEND_HANDLE_FP; file_handle.handle.fp = VCWD_FOPEN(*p, "rb"); if ( file_handle.handle.fp ) {//.........这里部分代码省略.........
开发者ID:SammyK,项目名称:php-src,代码行数:101,
示例21: ONPHP_METHOD//.........这里部分代码省略......... name = estrdup(Z_STRVAL_PP(params[0])); length = strlen(name); if ( zend_hash_find( Z_ARRVAL_P(instances), name, length + 1, (void **) &stored ) == SUCCESS ) { efree(params); efree(name); object = *stored; zval_copy_ctor(object); } else { // stolen from Reflection's newInstance() if (zend_lookup_class(name, length, &cep TSRMLS_CC) == SUCCESS) { zval *retval_ptr; zend_fcall_info fci; zend_fcall_info_cache fcc; zend_class_entry *ce = *cep; // can use ce->name instead now efree(name); if (!instanceof_function(ce, onphp_ce_Singleton TSRMLS_CC)) { efree(params); ONPHP_THROW( WrongArgumentException, "Class '%s' is something not a Singleton's child", ce->name ); } // we can call protected consturctors, // since all classes are childs of Singleton if (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE) { efree(params); ONPHP_THROW( BaseException, "Can not call private constructor for '%s' creation", ce->name ); } else if (ce->constructor->common.fn_flags & ZEND_ACC_PUBLIC) { efree(params); ONPHP_THROW( BaseException, "Don't want to deal with '%s' class " "due to public constructor there", ce->name ); } ALLOC_INIT_ZVAL(object); object_init_ex(object, ce); fci.size = sizeof(fci); fci.function_table = EG(function_table); fci.function_name = NULL; fci.symbol_table = NULL; fci.object_pp = &object; fci.retval_ptr_ptr = &retval_ptr; fci.param_count = argc - 1; fci.params = params + 1; fcc.initialized = 1; fcc.function_handler = ce->constructor; fcc.calling_scope = EG(scope); fcc.object_pp = &object; if (zend_call_function(&fci, &fcc TSRMLS_CC) == FAILURE) { zend_throw_exception_ex( onphp_ce_BaseException, 0 TSRMLS_CC, "Failed to call '%s' constructor", ce->name ); } efree(params); if (retval_ptr) { zval_ptr_dtor(&retval_ptr); } if (EG(exception)) { return; } add_assoc_zval_ex(instances, ce->name, length + 1, object); } } RETURN_ZVAL(object, 1, 0);}
开发者ID:dshum,项目名称:Lemon-Tree-2.0,代码行数:101,
示例22: shutdown_executorvoid shutdown_executor(void) /* {{{ */{ zend_function *func; zend_class_entry *ce; zend_try {/* Removed because this can not be safely done, e.g. in this situation: Object 1 creates object 2 Object 3 holds reference to object 2. Now when 1 and 2 are destroyed, 3 can still access 2 in its destructor, with very problematic results *//* zend_objects_store_call_destructors(&EG(objects_store)); *//* Moved after symbol table cleaners, because some of the cleaners can call destructors, which would use EG(symtable_cache_ptr) and thus leave leaks *//* while (EG(symtable_cache_ptr)>=EG(symtable_cache)) { zend_hash_destroy(*EG(symtable_cache_ptr)); efree(*EG(symtable_cache_ptr)); EG(symtable_cache_ptr)--; }*/ zend_llist_apply(&zend_extensions, (llist_apply_func_t) zend_extension_deactivator); if (CG(unclean_shutdown)) { EG(symbol_table).pDestructor = zend_unclean_zval_ptr_dtor; } zend_hash_graceful_reverse_destroy(&EG(symbol_table)); } zend_end_try(); EG(valid_symbol_table) = 0; zend_try { zval *zeh; /* remove error handlers before destroying classes and functions, * so that if handler used some class, crash would not happen */ if (Z_TYPE(EG(user_error_handler)) != IS_UNDEF) { zeh = &EG(user_error_handler); zval_ptr_dtor(zeh); ZVAL_UNDEF(&EG(user_error_handler)); } if (Z_TYPE(EG(user_exception_handler)) != IS_UNDEF) { zeh = &EG(user_exception_handler); zval_ptr_dtor(zeh); ZVAL_UNDEF(&EG(user_exception_handler)); } zend_stack_clean(&EG(user_error_handlers_error_reporting), NULL, 1); zend_stack_clean(&EG(user_error_handlers), (void (*)(void *))ZVAL_DESTRUCTOR, 1); zend_stack_clean(&EG(user_exception_handlers), (void (*)(void *))ZVAL_DESTRUCTOR, 1); } zend_end_try(); zend_try { /* Cleanup static data for functions and arrays. * We need a separate cleanup stage because of the following problem: * Suppose we destroy class X, which destroys the class's function table, * and in the function table we have function foo() that has static $bar. * Now if an object of class X is assigned to $bar, its destructor will be * called and will fail since X's function table is in mid-destruction. * So we want first of all to clean up all data and then move to tables destruction. * Note that only run-time accessed data need to be cleaned up, pre-defined data can * not contain objects and thus are not probelmatic */ if (EG(full_tables_cleanup)) { ZEND_HASH_FOREACH_PTR(EG(function_table), func) { if (func->type == ZEND_USER_FUNCTION) { zend_cleanup_op_array_data((zend_op_array *) func); } } ZEND_HASH_FOREACH_END(); ZEND_HASH_REVERSE_FOREACH_PTR(EG(class_table), ce) { if (ce->type == ZEND_USER_CLASS) { zend_cleanup_user_class_data(ce); } else { zend_cleanup_internal_class_data(ce); } } ZEND_HASH_FOREACH_END(); } else { ZEND_HASH_REVERSE_FOREACH_PTR(EG(function_table), func) { if (func->type != ZEND_USER_FUNCTION) { break; } zend_cleanup_op_array_data((zend_op_array *) func); } ZEND_HASH_FOREACH_END(); ZEND_HASH_REVERSE_FOREACH_PTR(EG(class_table), ce) { if (ce->type != ZEND_USER_CLASS) { break; } zend_cleanup_user_class_data(ce); } ZEND_HASH_FOREACH_END(); zend_cleanup_internal_classes(); } } zend_end_try();
开发者ID:ante3,项目名称:php-src,代码行数:91,
示例23: while val = _tmp; / } while (0)/* End of zend_execute_locks.h */#define CV_OF(i) (EG(current_execute_data)->CVs[i])#define CV_DEF_OF(i) (EG(active_op_array)->vars[i])ZEND_API zval** zend_get_compiled_variable_value(zend_execute_data *execute_data_ptr, zend_uint var){ return execute_data_ptr->CVs[var];}static inline void zend_get_cv_address(zend_compiled_variable *cv, zval ***ptr, temp_variable *Ts TSRMLS_DC){ zval *new_zval = &EG(uninitialized_zval); new_zval->refcount++; zend_hash_quick_update(EG(active_symbol_table), cv->name, cv->name_len+1, cv->hash_value, &new_zval, sizeof(zval *), (void **)ptr);}static inline zval *_get_zval_ptr_tmp(znode *node, temp_variable *Ts, zend_free_op *should_free TSRMLS_DC){ return should_free->var = &T(node->u.var).tmp_var;}static inline zval *_get_zval_ptr_var(znode *node, temp_variable *Ts, zend_free_op *should_free TSRMLS_DC){ zval *ptr = T(node->u.var).var.ptr; if (ptr) { PZVAL_UNLOCK(ptr, should_free);
开发者ID:dashiwa,项目名称:php52-backports,代码行数:31,
示例24: php_var_unserialize2//.........这里部分代码省略......... maxlen = max - YYCURSOR; if (maxlen < len || len == 0) { *p = start + 2; return 0; } class_name = (char*)YYCURSOR; YYCURSOR += len; if (*(YYCURSOR) != '"') { *p = YYCURSOR; return 0; } if (*(YYCURSOR+1) != ':') { *p = YYCURSOR+1; return 0; } len3 = strspn(class_name, "0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/177/200/201/202/203/204/205/206/207/210/211/212/213/214/215/216/217/220/221/222/223/224/225/226/227/230/231/232/233/234/235/236/237/240/241/242/243/244/245/246/247/250/251/252/253/254/255/256/257/260/261/262/263/264/265/266/267/270/271/272/273/274/275/276/277/300/301/302/303/304/305/306/307/310/311/312/313/314/315/316/317/320/321/322/323/324/325/326/327/330/331/332/333/334/335/336/337/340/341/342/343/344/345/346/347/350/351/352/353/354/355/356/357/360/361/362/363/364/365/366/367/370/371/372/373/374/375/376/377//"); if (len3 != len) { *p = YYCURSOR + len3 - len; return 0; } class_name = estrndup(class_name, len); do { /* Try to find class directly */ UNSERIALIZE2_G(serialize_lock)++; if (zend_lookup_class(class_name, len2, &pce TSRMLS_CC) == SUCCESS) { UNSERIALIZE2_G(serialize_lock)--; if (EG(exception)) { efree(class_name); return 0; } ce = *pce; break; } UNSERIALIZE2_G(serialize_lock)--; if (EG(exception)) { efree(class_name); return 0; } /* Check for unserialize callback */ if ((PG(unserialize_callback_func) == NULL) || (PG(unserialize_callback_func)[0] == '/0')) { incomplete_class = 1; ce = PHP_IC_ENTRY; break; } /* Call unserialize callback */ MAKE_STD_ZVAL(user_func); ZVAL_STRING(user_func, PG(unserialize_callback_func), 1); args[0] = &arg_func_name; MAKE_STD_ZVAL(arg_func_name); ZVAL_STRING(arg_func_name, class_name, 1); UNSERIALIZE2_G(serialize_lock)++; if (call_user_function_ex(CG(function_table), NULL, user_func, &retval_ptr, 1, args, 0, NULL TSRMLS_CC) != SUCCESS) { UNSERIALIZE2_G(serialize_lock)--; if (EG(exception)) { efree(class_name); zval_ptr_dtor(&user_func);
开发者ID:qiaolun,项目名称:unserialize,代码行数:67,
示例25: PHP_METHOD/* {{{ MongoCursor->next */PHP_METHOD(MongoCursor, next) { zval has_next; mongo_cursor *cursor; PHP_MONGO_GET_CURSOR(getThis()); if (!cursor->started_iterating) { MONGO_METHOD(MongoCursor, doQuery, return_value, getThis()); if (EG(exception)) { return; } cursor->started_iterating = 1; } // destroy old current if (cursor->current) { zval_ptr_dtor(&cursor->current); cursor->current = 0; } // check for results MONGO_METHOD(MongoCursor, hasNext, &has_next, getThis()); if (EG(exception)) { return; } if (!Z_BVAL(has_next)) { // we're out of results RETURN_NULL(); } // we got more results if (cursor->at < cursor->num) { zval **err; MAKE_STD_ZVAL(cursor->current); array_init(cursor->current); cursor->buf.pos = bson_to_zval((char*)cursor->buf.pos, Z_ARRVAL_P(cursor->current) TSRMLS_CC); if (EG(exception)) { zval_ptr_dtor(&cursor->current); cursor->current = 0; return; } // increment cursor position cursor->at++; // check for err if (cursor->num == 1 && zend_hash_find(Z_ARRVAL_P(cursor->current), "$err", strlen("$err")+1, (void**)&err) == SUCCESS) { zval **code_z; // default error code int code = 4; if (zend_hash_find(Z_ARRVAL_P(cursor->current), "code", strlen("code")+1, (void**)&code_z) == SUCCESS) { // check for not master if (Z_TYPE_PP(code_z) == IS_LONG) { code = Z_LVAL_PP(code_z); } else if (Z_TYPE_PP(code_z) == IS_DOUBLE) { code = (int)Z_DVAL_PP(code_z); } // else code == 4 // this shouldn't be necessary after 1.7.* is standard, it forces // failover in case the master steps down. // not master: 10107 // not master and slaveok=false (more recent): 13435 // not master or secondary: 13436 if (cursor->link->rs && (code == 10107 || code == 13435 || code == 13436)) { php_mongo_disconnect_server(cursor->server); } } zend_throw_exception(mongo_ce_CursorException, Z_STRVAL_PP(err), code TSRMLS_CC); zval_ptr_dtor(&cursor->current); cursor->current = 0; RETURN_FALSE; } } RETURN_NULL();}
开发者ID:skylerjohnson80,项目名称:mongo-php-driver,代码行数:84,
示例26: zend_init_exception_opstatic void zend_init_exception_op(void) /* {{{ */{ memset(EG(exception_op), 0, sizeof(EG(exception_op))); EG(exception_op)[0].opcode = ZEND_HANDLE_EXCEPTION; EG(exception_op)[0].op1_type = IS_UNUSED; EG(exception_op)[0].op2_type = IS_UNUSED; EG(exception_op)[0].result_type = IS_UNUSED; ZEND_VM_SET_OPCODE_HANDLER(EG(exception_op)); EG(exception_op)[1].opcode = ZEND_HANDLE_EXCEPTION; EG(exception_op)[1].op1_type = IS_UNUSED; EG(exception_op)[1].op2_type = IS_UNUSED; EG(exception_op)[1].result_type = IS_UNUSED; ZEND_VM_SET_OPCODE_HANDLER(EG(exception_op)+1); EG(exception_op)[2].opcode = ZEND_HANDLE_EXCEPTION; EG(exception_op)[2].op1_type = IS_UNUSED; EG(exception_op)[2].op2_type = IS_UNUSED; EG(exception_op)[2].result_type = IS_UNUSED; ZEND_VM_SET_OPCODE_HANDLER(EG(exception_op)+2);}
开发者ID:ahamid,项目名称:php-src,代码行数:19,
示例27: php_runkit_check_call_stack |