这篇教程C++ zval_ptr_dtor函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中zval_ptr_dtor函数的典型用法代码示例。如果您正苦于以下问题:C++ zval_ptr_dtor函数的具体用法?C++ zval_ptr_dtor怎么用?C++ zval_ptr_dtor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了zval_ptr_dtor函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: mlfi_envrcpt/* {{{ mlfi_envrcpt()*/static sfsistat mlfi_envrcpt(SMFICTX *ctx, char **argv){ zval function_name, retval, *param[1]; int status; TSRMLS_FETCH(); /* call userland */ INIT_ZVAL(function_name); ALLOC_ZVAL(param[0]); INIT_PZVAL(param[0]); ZVAL_STRING(&function_name, "milter_envrcpt", 0); array_init(param[0]); while (*argv) { add_next_index_string(param[0], *argv, 1); argv++; } /* set the milter context for possible use in API functions */ MG(ctx) = ctx; MG(state) = MLFI_ENVRCPT; status = call_user_function(CG(function_table), NULL, &function_name, &retval, 1, param TSRMLS_CC); MG(state) = MLFI_NONE; zval_ptr_dtor(param); if (status == SUCCESS && Z_TYPE(retval) == IS_LONG) { return Z_LVAL(retval); } return SMFIS_CONTINUE;}
开发者ID:vpj,项目名称:PHP-Extension-API,代码行数:38,
示例2: pthreads_read_property/* {{ reads a property from a thread, wherever it is available */zval * pthreads_read_property (PTHREADS_READ_PROPERTY_PASSTHRU_D) { zval *value = NULL, *mstring = NULL; PTHREAD pthreads = PTHREADS_FETCH_FROM(object); if (Z_TYPE_P(member) != IS_STRING) { ALLOC_ZVAL(mstring); *mstring = *member; zval_copy_ctor( mstring ); INIT_PZVAL(mstring); convert_to_string(mstring); member = mstring;#if PHP_VERSION_ID > 50399 key = NULL;#endif } if (Z_TYPE_P(member)==IS_STRING) { pthreads_store_read(pthreads->store, Z_STRVAL_P(member), Z_STRLEN_P(member), &value TSRMLS_CC); } else { zend_error(E_WARNING, "pthreads detected an attempt to use an unsupported kind of key in %s", Z_OBJCE_P(object)->name); if (value != NULL) { value = EG( uninitialized_zval_ptr ); Z_ADDREF_P(value); } } if (mstring != NULL) { zval_ptr_dtor(&mstring); } return value;}
开发者ID:igodz,项目名称:pthreads,代码行数:37,
示例3: php_free_stmt_bind_buffer/* {{{ php_free_stmt_bind_buffer */void php_free_stmt_bind_buffer(BIND_BUFFER bbuf, int type){ unsigned int i; if (!bbuf.var_cnt) { return; } for (i=0; i < bbuf.var_cnt; i++) { /* free temporary bind buffer */ if (type == FETCH_RESULT && bbuf.buf[i].val) { efree(bbuf.buf[i].val); } zval_ptr_dtor(&bbuf.vars[i]); } if (bbuf.vars) { efree(bbuf.vars); } /* Don't free bbuf.is_null for FETCH_RESULT since we have allocated is_null and buf in one block so we free only buf, which is the beginning of the block. When FETCH_SIMPLE then buf wasn't allocated together with buf and we have to free it. */ if (type == FETCH_RESULT) { efree(bbuf.buf); } else if (type == FETCH_SIMPLE){ efree(bbuf.is_null); } bbuf.var_cnt = 0;}
开发者ID:IMSoP,项目名称:php-src,代码行数:37,
示例4: php_zlib_output_compression_start/* {{{ php_zlib_output_compression_start() */static void php_zlib_output_compression_start(void){ zval zoh; php_output_handler *h; switch (ZLIBG(output_compression)) { case 0: break; case 1: ZLIBG(output_compression) = PHP_OUTPUT_HANDLER_DEFAULT_SIZE; /* break omitted intentionally */ default: if ( php_zlib_output_encoding() && (h = php_zlib_output_handler_init(ZEND_STRL(PHP_ZLIB_OUTPUT_HANDLER_NAME), ZLIBG(output_compression), PHP_OUTPUT_HANDLER_STDFLAGS)) && (SUCCESS == php_output_handler_start(h))) { if (ZLIBG(output_handler) && *ZLIBG(output_handler)) { ZVAL_STRING(&zoh, ZLIBG(output_handler)); php_output_start_user(&zoh, ZLIBG(output_compression), PHP_OUTPUT_HANDLER_STDFLAGS); zval_ptr_dtor(&zoh); } } break; }}
开发者ID:Freeaqingme,项目名称:php-src,代码行数:25,
示例5: PHP_METHODPHP_METHOD(MongoDB, selectCollection){ zval temp; zval *z_collection; char *collection; int collection_len; mongo_db *db; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &collection, &collection_len) == FAILURE) { return; } MAKE_STD_ZVAL(z_collection); ZVAL_STRINGL(z_collection, collection, collection_len, 1); db = (mongo_db*)zend_object_store_get_object(getThis() TSRMLS_CC); MONGO_CHECK_INITIALIZED(db->name, MongoDB); object_init_ex(return_value, mongo_ce_Collection); MONGO_METHOD2(MongoCollection, __construct, &temp, return_value, getThis(), z_collection); zval_ptr_dtor(&z_collection);}
开发者ID:tipiak75,项目名称:mongo-php-driver,代码行数:24,
示例6: PHP_INI_MHstatic PHP_INI_MH(OnChangeCallback) /* {{{ */{ if (EG(current_execute_data)) { if (Z_TYPE(ASSERTG(callback)) != IS_UNDEF) { zval_ptr_dtor(&ASSERTG(callback)); ZVAL_UNDEF(&ASSERTG(callback)); } if (new_value && (Z_TYPE(ASSERTG(callback)) != IS_UNDEF || ZSTR_LEN(new_value))) { ZVAL_STR_COPY(&ASSERTG(callback), new_value); } } else { if (ASSERTG(cb)) { pefree(ASSERTG(cb), 1); } if (new_value && ZSTR_LEN(new_value)) { ASSERTG(cb) = pemalloc(ZSTR_LEN(new_value) + 1, 1); memcpy(ASSERTG(cb), ZSTR_VAL(new_value), ZSTR_LEN(new_value)); ASSERTG(cb)[ZSTR_LEN(new_value)] = '/0'; } else { ASSERTG(cb) = NULL; } } return SUCCESS;}
开发者ID:husman,项目名称:php-src,代码行数:24,
示例7: MYSQLND_METHOD/* {{{ mysqlnd_vio::enable_ssl */static enum_func_statusMYSQLND_METHOD(mysqlnd_vio, enable_ssl)(MYSQLND_VIO * const net){#ifdef MYSQLND_SSL_SUPPORTED php_stream_context * context = php_stream_context_alloc(); php_stream * net_stream = net->data->m.get_stream(net); zend_bool any_flag = FALSE; DBG_ENTER("mysqlnd_vio::enable_ssl"); if (!context) { DBG_RETURN(FAIL); } if (net->data->options.ssl_key) { zval key_zval; ZVAL_STRING(&key_zval, net->data->options.ssl_key); php_stream_context_set_option(context, "ssl", "local_pk", &key_zval); zval_ptr_dtor(&key_zval); any_flag = TRUE; } if (net->data->options.ssl_cert) { zval cert_zval; ZVAL_STRING(&cert_zval, net->data->options.ssl_cert); php_stream_context_set_option(context, "ssl", "local_cert", &cert_zval); if (!net->data->options.ssl_key) { php_stream_context_set_option(context, "ssl", "local_pk", &cert_zval); } zval_ptr_dtor(&cert_zval); any_flag = TRUE; } if (net->data->options.ssl_ca) { zval cafile_zval; ZVAL_STRING(&cafile_zval, net->data->options.ssl_ca); php_stream_context_set_option(context, "ssl", "cafile", &cafile_zval); any_flag = TRUE; } if (net->data->options.ssl_capath) { zval capath_zval; ZVAL_STRING(&capath_zval, net->data->options.ssl_capath); php_stream_context_set_option(context, "ssl", "capath", &capath_zval); zval_ptr_dtor(&capath_zval); any_flag = TRUE; } if (net->data->options.ssl_passphrase) { zval passphrase_zval; ZVAL_STRING(&passphrase_zval, net->data->options.ssl_passphrase); php_stream_context_set_option(context, "ssl", "passphrase", &passphrase_zval); zval_ptr_dtor(&passphrase_zval); any_flag = TRUE; } if (net->data->options.ssl_cipher) { zval cipher_zval; ZVAL_STRING(&cipher_zval, net->data->options.ssl_cipher); php_stream_context_set_option(context, "ssl", "ciphers", &cipher_zval); zval_ptr_dtor(&cipher_zval); any_flag = TRUE; } { zval verify_peer_zval; zend_bool verify; if (net->data->options.ssl_verify_peer == MYSQLND_SSL_PEER_DEFAULT) { net->data->options.ssl_verify_peer = any_flag? MYSQLND_SSL_PEER_DEFAULT_ACTION:MYSQLND_SSL_PEER_DONT_VERIFY; } verify = net->data->options.ssl_verify_peer == MYSQLND_SSL_PEER_VERIFY? TRUE:FALSE; DBG_INF_FMT("VERIFY=%d", verify); ZVAL_BOOL(&verify_peer_zval, verify); php_stream_context_set_option(context, "ssl", "verify_peer", &verify_peer_zval); php_stream_context_set_option(context, "ssl", "verify_peer_name", &verify_peer_zval); if (net->data->options.ssl_verify_peer == MYSQLND_SSL_PEER_DONT_VERIFY) { ZVAL_TRUE(&verify_peer_zval); php_stream_context_set_option(context, "ssl", "allow_self_signed", &verify_peer_zval); } }#if PHP_API_VERSION >= 20131106 php_stream_context_set(net_stream, context);#else php_stream_context_set(net_stream, context);#endif if (php_stream_xport_crypto_setup(net_stream, STREAM_CRYPTO_METHOD_TLS_CLIENT, NULL) < 0 || php_stream_xport_crypto_enable(net_stream, 1) < 0) { DBG_ERR("Cannot connect to MySQL by using SSL"); php_error_docref(NULL, E_WARNING, "Cannot connect to MySQL by using SSL"); DBG_RETURN(FAIL); } net->data->ssl = TRUE; /* get rid of the context. we are persistent and if this is a real pconn used by mysql/mysqli, then the context would not survive cleaning of EG(regular_list), where it is registered, as a resource. What happens is that after this destruction any use of the network will mean usage of the context, which means usage of already freed memory, bad. Actually we don't need this context anymore after we have enabled SSL on the connection. Thus it is very simple, we remove it. */#if PHP_API_VERSION >= 20131106 php_stream_context_set(net_stream, NULL);#else//.........这里部分代码省略.........
开发者ID:MajorDeng,项目名称:php-src,代码行数:101,
示例8: kr_regex_replace_arr// need efreechar * kr_regex_replace_arr (char * regex_o[], char * replace_o[], char * str_o, int regex_no) // {{{{ zend_string * buf = NULL; zend_string * regex; zend_string * subject; int i;#if PHP_VERSION_ID < 70200 zval rep;#else zend_string * rep;#endif#if PHP_VERSION_ID < 70300 int repc = 0;#else size_t repc = 0;#endif char * sval; subject = ze_string_init (str_o, STRLEN (str_o), 0); for ( i=0; i<regex_no ; i++ ) { regex = ze_string_init (regex_o[i], STRLEN (regex_o[i]), 0);#if PHP_VERSION_ID < 70200 ZVAL_STRINGL (&rep, replace_o[i], STRLEN (replace_o[i]));#else rep = ze_string_init (replace_o[i], STRLEN (replace_o[i]), 0);#endif if ( i != 0 ) { subject = zend_string_dup (buf, 0); zend_string_release(buf); buf = NULL; } /* php_printf ("regex ########### %s/n", ZSTR_VAL (regex)); php_printf ("subject ######### %s/n", ZSTR_VAL (subject)); php_printf ("subjlen ######### %d/n", ZSTR_LEN (subject)); php_printf ("replace ######### %s/n", ZSTR_VAL (rep.value.str)); php_printf ("replace ######### %s/n", Z_STRVAL (rep.value.str)); */ buf = php_pcre_replace ( regex, subject, ZSTR_VAL (subject), ZSTR_LEN (subject),#if PHP_VERSION_ID < 70200 &rep, 0,#else rep,#endif -1, &repc );#if PHP_VERSION_ID < 70200 zval_ptr_dtor (&rep);#else zend_string_release (rep);#endif zend_string_release (regex); zend_string_release (subject); } sval = estrdup (ZSTR_VAL (buf)); zend_string_release (buf); return sval;} // }}}
开发者ID:OOPS-ORG-PHP,项目名称:mod_korean,代码行数:73,
示例9: PHP_METHODPHP_METHOD(MongoDB, command) { zval limit, *temp, *cmd, *cursor, *ns, *options = 0; mongo_db *db; mongo_link *link; char *cmd_ns; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|a", &cmd, &options) == FAILURE) { return; } if (IS_SCALAR_P(cmd)) { zend_error(E_WARNING, "MongoDB::command() expects parameter 1 to be an array or object"); return; } PHP_MONGO_GET_DB(getThis()); // create db.$cmd MAKE_STD_ZVAL(ns); cmd_ns = get_cmd_ns(Z_STRVAL_P(db->name), Z_STRLEN_P(db->name)); ZVAL_STRING(ns, cmd_ns, 0); // create cursor MAKE_STD_ZVAL(cursor); object_init_ex(cursor, mongo_ce_Cursor); MAKE_STD_ZVAL(temp); ZVAL_NULL(temp); MONGO_METHOD3(MongoCursor, __construct, temp, cursor, db->link, ns, cmd); zval_ptr_dtor(&ns); zval_ptr_dtor(&temp); MAKE_STD_ZVAL(temp); ZVAL_NULL(temp); // limit Z_TYPE(limit) = IS_LONG; Z_LVAL(limit) = -1; MONGO_METHOD1(MongoCursor, limit, temp, cursor, &limit); zval_ptr_dtor(&temp); if (options) { zval **timeout; if (zend_hash_find(HASH_P(options), "timeout", strlen("timeout")+1, (void**)&timeout) == SUCCESS) { MAKE_STD_ZVAL(temp); ZVAL_NULL(temp); MONGO_METHOD1(MongoCursor, timeout, temp, cursor, *timeout); zval_ptr_dtor(&temp); } } // make sure commands aren't be sent to slaves PHP_MONGO_GET_LINK(db->link); if (link->rs) { zval slave_okay; Z_TYPE(slave_okay) = IS_BOOL; Z_LVAL(slave_okay) = 0; MAKE_STD_ZVAL(temp); ZVAL_NULL(temp); MONGO_METHOD1(MongoCursor, slaveOkay, temp, cursor, &slave_okay); zval_ptr_dtor(&temp); } // query MONGO_METHOD(MongoCursor, getNext, return_value, cursor); clear_exception(return_value TSRMLS_CC); zend_objects_store_del_ref(cursor TSRMLS_CC); zval_ptr_dtor(&cursor);}
开发者ID:cockatoo-org,项目名称:mongo-php-driver,代码行数:71,
示例10: PHP_METHODPHP_METHOD(air_view, render){ AIR_INIT_THIS; char *tpl_str; int tpl_len = 0; zend_bool ret_res = 0; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sb", &tpl_str, &tpl_len, &ret_res) == FAILURE) { RETURN_FALSE; } smart_str ss_path = {0}; if(tpl_str[0] != '/'){ zval *root_path = NULL; MAKE_STD_ZVAL(root_path); if(zend_get_constant(ZEND_STRL("ROOT_PATH"), root_path) == FAILURE){ php_error_docref(NULL TSRMLS_CC, E_ERROR, "ROOT_PATH not defined"); } smart_str_appendl(&ss_path, Z_STRVAL_P(root_path), Z_STRLEN_P(root_path)); smart_str_appendc(&ss_path, '/'); if(root_path != NULL){ zval_ptr_dtor(&root_path); } zval *tmp = NULL; zval **tmp_pp; zval *config = zend_read_property(air_view_ce, getThis(), ZEND_STRL("_config"), 0 TSRMLS_CC); if(config != NULL && Z_TYPE_P(config) == IS_ARRAY && zend_hash_find(Z_ARRVAL_P(config), ZEND_STRL("path"), (void **)&tmp_pp) == SUCCESS){ smart_str_appendl(&ss_path, Z_STRVAL_PP(tmp_pp), Z_STRLEN_PP(tmp_pp)); }else{ zval *app_conf; zval *view_conf; if(air_config_get(NULL, ZEND_STRS("app"), &app_conf TSRMLS_CC) == FAILURE){ AIR_NEW_EXCEPTION(1, "@error config: app"); } zval *app_path = NULL; if(air_config_get(app_conf, ZEND_STRS("path"), &app_path) == FAILURE){ AIR_NEW_EXCEPTION(1, "@error config: app.path"); } zval *view_path = NULL; if(air_config_get_path(app_conf, ZEND_STRS("view.path"), &view_path) == FAILURE){ AIR_NEW_EXCEPTION(1, "@view config not found"); } smart_str_appendl(&ss_path, Z_STRVAL_P(app_path), Z_STRLEN_P(app_path)); smart_str_appendc(&ss_path, '/'); smart_str_appendl(&ss_path, Z_STRVAL_P(view_path), Z_STRLEN_P(view_path)); } smart_str_appendc(&ss_path, '/'); } smart_str_appendl(&ss_path, tpl_str, tpl_len); smart_str_0(&ss_path); //php_printf("full view path: %s/n", ss_path.c); //构造运行时所需基本变量 HashTable *origin_symbol_table = NULL; zval *output_handler = NULL; long chunk_size = 0; long flags = PHP_OUTPUT_HANDLER_STDFLAGS; zval *view_ret = NULL; //尝试缓存当前符号表 if(EG(active_symbol_table)){ origin_symbol_table = EG(active_symbol_table); } if (ret_res) { MAKE_STD_ZVAL(view_ret); if(php_output_start_user(output_handler, chunk_size, flags TSRMLS_CC) == FAILURE) { php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to create buffer"); RETURN_FALSE; } } ALLOC_HASHTABLE(EG(active_symbol_table)); zval *data = zend_read_property(air_view_ce, getThis(), ZEND_STRL("_data"), 0 TSRMLS_CC); zend_hash_init(EG(active_symbol_table), 0, NULL, ZVAL_PTR_DTOR, 0); //将当前的模板变量放到符号表去 ZEND_SET_SYMBOL_WITH_LENGTH(EG(active_symbol_table), "var", 4, data, Z_REFCOUNT_P(data) + 1, PZVAL_IS_REF(data)); if(air_loader_include_file(ss_path.c TSRMLS_CC) == FAILURE){ air_throw_exception_ex(1, "tpl %s render failed!/n", ss_path.c); return ; } if(ret_res){ php_output_get_contents(view_ret TSRMLS_CC); php_output_discard(TSRMLS_C); RETVAL_ZVAL(view_ret, 1, 0); zval_ptr_dtor(&view_ret); } zend_hash_destroy(EG(active_symbol_table)); FREE_HASHTABLE(EG(active_symbol_table)); EG(active_symbol_table) = origin_symbol_table; smart_str_free(&ss_path);}
开发者ID:panbooks,项目名称:air,代码行数:98,
示例11: PHP_FUNCTIONU_CFUNC PHP_FUNCTION(intlcal_to_date_time){ zval retval; CALENDAR_METHOD_INIT_VARS; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &object, Calendar_ce_ptr) == FAILURE) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "intlcal_to_date_time: bad arguments", 0 TSRMLS_CC); RETURN_FALSE; } CALENDAR_METHOD_FETCH_OBJECT; /* There are no exported functions in ext/date to this * in a more native fashion */ double date = co->ucal->getTime(CALENDAR_ERROR_CODE(co)) / 1000.; int64_t ts; char ts_str[sizeof("@-9223372036854775808")]; int ts_str_len; zval ts_tmp, ts_zval, tmp; INTL_METHOD_CHECK_STATUS(co, "Call to ICU method has failed"); if (date > (double)U_INT64_MAX || date < (double)U_INT64_MIN) { intl_errors_set(CALENDAR_ERROR_P(co), U_ILLEGAL_ARGUMENT_ERROR, "intlcal_to_date_time: The calendar date is out of the " "range for a 64-bit integer", 0 TSRMLS_CC); RETURN_FALSE; } ZVAL_UNDEF(&retval); ts = (int64_t)date; ts_str_len = slprintf(ts_str, sizeof(ts_str), "@%I64d", ts); ZVAL_STRINGL(&ts_zval, ts_str, ts_str_len); /* Now get the time zone */ const TimeZone& tz = co->ucal->getTimeZone(); zval *timezone_zval = timezone_convert_to_datetimezone( &tz, CALENDAR_ERROR_P(co), "intlcal_to_date_time", &tmp TSRMLS_CC); if (timezone_zval == NULL) { RETURN_FALSE; } /* resources allocated from now on */ /* Finally, instantiate object and call constructor */ object_init_ex(return_value, php_date_get_date_ce()); zend_call_method_with_2_params(return_value, NULL, NULL, "__construct", NULL, &ts_zval, timezone_zval); if (EG(exception)) { intl_errors_set(CALENDAR_ERROR_P(co), U_ILLEGAL_ARGUMENT_ERROR, "intlcal_to_date_time: DateTime constructor has thrown exception", 1 TSRMLS_CC); zend_object_store_ctor_failed(Z_OBJ_P(return_value) TSRMLS_CC); zval_ptr_dtor(return_value); zval_ptr_dtor(&ts_zval); RETVAL_FALSE; goto error; } zval_ptr_dtor(&ts_zval); /* due to bug #40743, we have to set the time zone again */ zend_call_method_with_1_params(return_value, NULL, NULL, "settimezone", &retval, timezone_zval); if (Z_ISUNDEF(retval) || Z_TYPE(retval) == IS_FALSE) { intl_errors_set(CALENDAR_ERROR_P(co), U_ILLEGAL_ARGUMENT_ERROR, "intlcal_to_date_time: call to DateTime::setTimeZone has failed", 1 TSRMLS_CC); zval_ptr_dtor(return_value); RETVAL_FALSE; goto error; }error: zval_ptr_dtor(timezone_zval); zval_ptr_dtor(&retval);}
开发者ID:forgotting,项目名称:php-src,代码行数:79,
示例12: PHP_METHODPHP_METHOD(MongoGridFS, __construct) { zval *zdb, *files = 0, *chunks = 0, *zchunks; // chunks is deprecated if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|zz", &zdb, mongo_ce_DB, &files, &chunks) == FAILURE) { zval *object = getThis(); ZVAL_NULL(object); return; } if (!files && !chunks) { MAKE_STD_ZVAL(files); ZVAL_STRING(files, "fs.files", 1); MAKE_STD_ZVAL(chunks); ZVAL_STRING(chunks, "fs.chunks", 1); } else { zval *temp_file; char *temp; if (Z_TYPE_P(files) != IS_STRING || Z_STRLEN_P(files) == 0 ) {#if ZEND_MODULE_API_NO >= 20060613 zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 0 TSRMLS_CC, "MongoGridFS::__construct(): invalid prefix");#else zend_throw_exception_ex(zend_exception_get_default(), 0 TSRMLS_CC, "MongoGridFS::__construct(): invalid prefix");#endif /* ZEND_MODULE_API_NO >= 20060613 */ return; } MAKE_STD_ZVAL(chunks); spprintf(&temp, 0, "%s.chunks", Z_STRVAL_P(files)); ZVAL_STRING(chunks, temp, 0); MAKE_STD_ZVAL(temp_file); spprintf(&temp, 0, "%s.files", Z_STRVAL_P(files)); ZVAL_STRING(temp_file, temp, 0); files = temp_file; } // create files collection MONGO_METHOD2(MongoCollection, __construct, return_value, getThis(), zdb, files); // create chunks collection MAKE_STD_ZVAL(zchunks); object_init_ex(zchunks, mongo_ce_Collection); MONGO_METHOD2(MongoCollection, __construct, return_value, zchunks, zdb, chunks); // add chunks collection as a property zend_update_property(mongo_ce_GridFS, getThis(), "chunks", strlen("chunks"), zchunks TSRMLS_CC); zend_update_property(mongo_ce_GridFS, getThis(), "filesName", strlen("filesName"), files TSRMLS_CC); zend_update_property(mongo_ce_GridFS, getThis(), "chunksName", strlen("chunksName"), chunks TSRMLS_CC); // cleanup zval_ptr_dtor(&zchunks); zval_ptr_dtor(&files); zval_ptr_dtor(&chunks);}
开发者ID:IvanBozhakov,项目名称:mongo-php-driver,代码行数:61,
示例13: zephir_memory_restore_stack_common/** * Restore a memory stack applying GC to all observed variables */static void zephir_memory_restore_stack_common(zend_zephir_globals_def *g){ size_t i; zephir_memory_entry *prev, *active_memory; zephir_symbol_table *active_symbol_table; zval *ptr;#ifndef ZEPHIR_RELEASE int show_backtrace = 0;#endif active_memory = g->active_memory; assert(active_memory != NULL); if (EXPECTED(!CG(unclean_shutdown))) { /* Clean active symbol table */ if (g->active_symbol_table) { active_symbol_table = g->active_symbol_table; if (active_symbol_table->scope == active_memory) { zend_execute_data *ex = EG(current_execute_data); //zend_hash_destroy(EG(current_execute_data)->symbol_table); //FREE_HASHTABLE(EG(current_execute_data)->symbol_table); //EG(current_execute_data)->symbol_table = active_symbol_table->symbol_table; ex->symbol_table = active_symbol_table->symbol_table; g->active_symbol_table = active_symbol_table->prev; efree(active_symbol_table); } } /* Check for non freed hash key zvals, mark as null to avoid string freeing */ for (i = 0; i < active_memory->hash_pointer; ++i) { assert(active_memory->hash_addresses[i] != NULL); if (!Z_REFCOUNTED_P(active_memory->hash_addresses[i])) continue; if (Z_REFCOUNT_P(active_memory->hash_addresses[i]) <= 1) { ZVAL_NULL(active_memory->hash_addresses[i]); } else { zval_copy_ctor(active_memory->hash_addresses[i]); } }#ifndef ZEPHIR_RELEASE for (i = 0; i < active_memory->pointer; ++i) { if (active_memory->addresses[i] != NULL) { zval *var = active_memory->addresses[i]; if (Z_TYPE_P(var) > IS_CALLABLE) { fprintf(stderr, "%s: observed variable #%d (%p) has invalid type %u [%s]/n", __func__, (int)i, var, Z_TYPE_P(var), active_memory->func); show_backtrace = 1; } if (!Z_REFCOUNTED_P(var)) { continue; } if (Z_REFCOUNT_P(var) == 0) { fprintf(stderr, "%s: observed variable #%d (%p) has 0 references, type=%d [%s]/n", __func__, (int)i, var, Z_TYPE_P(var), active_memory->func); show_backtrace = 1; } else if (Z_REFCOUNT_P(var) >= 1000000) { fprintf(stderr, "%s: observed variable #%d (%p) has too many references (%u), type=%d [%s]/n", __func__, (int)i, var, Z_REFCOUNT_P(var), Z_TYPE_P(var), active_memory->func); show_backtrace = 1; }#if 0 /* Skip this check, PDO does return variables with is_ref = 1 and refcount = 1*/ else if (Z_REFCOUNT_PP(var) == 1 && Z_ISREF_PP(var)) { fprintf(stderr, "%s: observed variable #%d (%p) is a reference with reference count = 1, type=%d [%s]/n", __func__, (int)i, *var, Z_TYPE_PP(var), active_memory->func); }#endif } }#endif /* Traverse all zvals allocated, reduce the reference counting or free them */ for (i = 0; i < active_memory->pointer; ++i) { ptr = active_memory->addresses[i]; if (EXPECTED(ptr != NULL)) { if (!Z_REFCOUNTED_P(ptr)) continue; if (Z_REFCOUNT_P(ptr) == 1) { zval_ptr_dtor(ptr); } else { Z_DELREF_P(ptr); } } } }#ifndef ZEPHIR_RELEASE active_memory->func = NULL;#endif prev = active_memory->prev; if (active_memory >= g->end_memory || active_memory < g->start_memory) {#ifndef ZEPHIR_RELEASE assert(g->active_memory->permanent == 0);#endif assert(prev != NULL); if (active_memory->hash_addresses != NULL) {//.........这里部分代码省略.........
开发者ID:fanngx,项目名称:zephir,代码行数:101,
示例14: php_formatted_print//.........这里部分代码省略......... Z_STRVAL_P(var), width, precision, padding, alignment, Z_STRLEN_P(var), 0, expprec, 0); if (use_copy) { zval_dtor(&var_copy); } break; } case 'd': convert_to_long(tmp); php_sprintf_appendint(&result, &outpos, &size, Z_LVAL_P(tmp), width, padding, alignment, always_sign); break; case 'u': convert_to_long(tmp); php_sprintf_appenduint(&result, &outpos, &size, Z_LVAL_P(tmp), width, padding, alignment); break; case 'g': case 'G': case 'e': case 'E': case 'f': case 'F': convert_to_double(tmp); php_sprintf_appenddouble(&result, &outpos, &size, Z_DVAL_P(tmp), width, padding, alignment, precision, adjusting, format[inpos], always_sign TSRMLS_CC); break; case 'c': convert_to_long(tmp); php_sprintf_appendchar(&result, &outpos, &size, (char) Z_LVAL_P(tmp) TSRMLS_CC); break; case 'o': convert_to_long(tmp); php_sprintf_append2n(&result, &outpos, &size, Z_LVAL_P(tmp), width, padding, alignment, 3, hexchars, expprec); break; case 'x': convert_to_long(tmp); php_sprintf_append2n(&result, &outpos, &size, Z_LVAL_P(tmp), width, padding, alignment, 4, hexchars, expprec); break; case 'X': convert_to_long(tmp); php_sprintf_append2n(&result, &outpos, &size, Z_LVAL_P(tmp), width, padding, alignment, 4, HEXCHARS, expprec); break; case 'b': convert_to_long(tmp); php_sprintf_append2n(&result, &outpos, &size, Z_LVAL_P(tmp), width, padding, alignment, 1, hexchars, expprec); break; case '%': php_sprintf_appendchar(&result, &outpos, &size, '%' TSRMLS_CC); break; default: break; } if (multiuse) { zval_ptr_dtor(&tmp); } inpos++; } } efree(args); /* possibly, we have to make sure we have room for the terminating null? */ result[outpos]=0; *len = outpos; return result;}
开发者ID:NobleGaz,项目名称:PHP,代码行数:101,
示例15: phpg_closure_marshalstatic void phpg_closure_marshal(GClosure *closure, GValue *return_value, guint n_param_values, const GValue *param_values, gpointer invocation_hint, gpointer marshal_data){ phpg_closure_t *phpg_closure = (phpg_closure_t *)closure; char *callback_name; zval ***params = NULL; zval *retval = NULL; uint n_params = 0, i;#ifdef ZTS TSRMLS_D = phpg_closure->TSRMLS_C;#endif if (!zend_is_callable(phpg_closure->callback, 0, &callback_name PHPGTK_ZEND_IS_CALLABLE)) { if (phpg_closure->src_filename) php_error(E_WARNING, "Unable to invoke signal callback '%s' specified in %s on line %d", callback_name, phpg_closure->src_filename, phpg_closure->src_lineno); else php_error(E_WARNING, "Unable to invoke signal callback '%s'", callback_name); efree(callback_name); return; } if (phpg_closure->connect_type == PHPG_CONNECT_SIMPLE) { /* we don't use any signal params for simple connections */ n_param_values = 0; } else { if (phpg_closure->connect_type == PHPG_CONNECT_OBJECT) { /* skip first parameter */ n_param_values--; param_values++; } n_params = n_param_values; } if (phpg_closure->user_args) { n_params += zend_hash_num_elements(Z_ARRVAL_P(phpg_closure->user_args)); } params = (zval ***)emalloc(n_params * sizeof(zval **)); i = 0; if (phpg_closure->connect_type == PHPG_CONNECT_REPLACE) { params[i++] = &phpg_closure->replace_object; } for ( ; i < n_param_values; i++) { params[i] = (zval **) emalloc(sizeof(zval *)); *(params[i]) = NULL; if (phpg_gvalue_to_zval(¶m_values[i], params[i], FALSE, TRUE TSRMLS_CC) != SUCCESS) { goto err_marshal; } } if (phpg_closure->user_args) { for (zend_hash_internal_pointer_reset(Z_ARRVAL_P(phpg_closure->user_args)); zend_hash_get_current_data(Z_ARRVAL_P(phpg_closure->user_args), (void **)¶ms[i]) == SUCCESS; zend_hash_move_forward(Z_ARRVAL_P(phpg_closure->user_args)), i++); /* empty body */ } assert(i == n_params); call_user_function_ex(EG(function_table), NULL, phpg_closure->callback, &retval, n_params, params, 0, NULL TSRMLS_CC); if (retval) { if (return_value) { if (phpg_gvalue_from_zval(return_value, &retval, TRUE TSRMLS_CC) == FAILURE) { php_error(E_WARNING, "Could not convert return value of signal callback '%s' to '%s'", callback_name, g_type_name(G_VALUE_TYPE(return_value))); } } zval_ptr_dtor(&retval); }err_marshal: efree(callback_name); i = (phpg_closure->connect_type == PHPG_CONNECT_REPLACE) ? 1 : 0; for ( ; i < n_param_values; i++) { zval_ptr_dtor(params[i]); efree(params[i]); } efree(params); phpg_handle_marshaller_exception(TSRMLS_C);}
开发者ID:IgorDePaula,项目名称:php-gtk-src,代码行数:90,
示例16: php_yar_socket_execyar_response_t * php_yar_socket_exec(yar_transport_interface_t* self, yar_request_t *request) /* {{{ */ { fd_set rfds; struct timeval tv; yar_header_t *header; yar_response_t *response; int fd, retval, recvd; size_t len = 0, total_recvd = 0; char *msg, buf[RECV_BUF_SIZE], *payload = NULL; yar_socket_data_t *data = (yar_socket_data_t *)self->data; response = ecalloc(1, sizeof(yar_response_t)); FD_ZERO(&rfds); if (SUCCESS == php_stream_cast(data->stream, PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL, (void*)&fd, 1) && fd >= 0) { PHP_SAFE_FD_SET(fd, &rfds); } else { len = snprintf(buf, sizeof(buf), "Unable cast socket fd form stream (%s)", strerror(errno)); php_yar_response_set_error(response, YAR_ERR_TRANSPORT, buf, len); return response; } tv.tv_sec = (ulong)(YAR_G(timeout) / 1000); tv.tv_usec = (ulong)((YAR_G(timeout) % 1000)? (YAR_G(timeout) & 1000) * 1000 : 0);wait_io: retval = php_select(fd+1, &rfds, NULL, NULL, &tv); if (retval == -1) { len = snprintf(buf, sizeof(buf), "Unable to select %d '%s'", fd, strerror(errno)); php_yar_response_set_error(response, YAR_ERR_TRANSPORT, buf, len); return response; } else if (retval == 0) { len = snprintf(buf, sizeof(buf), "select timeout %ldms reached", YAR_G(timeout)); php_yar_response_set_error(response, YAR_ERR_TRANSPORT, buf, len); return response; } if (PHP_SAFE_FD_ISSET(fd, &rfds)) { zval *retval, rret; if (!payload) { if ((recvd = php_stream_xport_recvfrom(data->stream, buf, sizeof(buf), 0, NULL, NULL, NULL)) > 0) { if (!(header = php_yar_protocol_parse(buf))) { php_yar_error(response, YAR_ERR_PROTOCOL, "malformed response header '%.32s'", payload); return response; } payload = emalloc(header->body_len); len = header->body_len; total_recvd = recvd - sizeof(yar_header_t); memcpy(payload, buf + sizeof(yar_header_t), total_recvd); if (recvd < (sizeof(yar_header_t) + len)) { goto wait_io; } } else if (recvd < 0) { /* this should never happen */ goto wait_io; } } else { if ((recvd = php_stream_xport_recvfrom(data->stream, payload + total_recvd, len - total_recvd, 0, NULL, NULL, NULL)) > 0) { total_recvd += recvd; } if (total_recvd < len) { goto wait_io; } } if (len) { if (!(retval = php_yar_packager_unpack(payload, len, &msg, &rret))) { php_yar_response_set_error(response, YAR_ERR_PACKAGER, msg, strlen(msg)); efree(msg); return response; } php_yar_response_map_retval(response, retval); DEBUG_C(ZEND_ULONG_FMT": server response content packaged by '%.*s', len '%ld', content '%.32s'", response->id, 7, payload, header->body_len, payload + 8); efree(payload); zval_ptr_dtor(retval); } else { php_yar_response_set_error(response, YAR_ERR_EMPTY_RESPONSE, ZEND_STRL("empty response")); } return response; } else { goto wait_io; }} /* }}} */
开发者ID:remicollet,项目名称:yar,代码行数:91,
示例17: php_var_unserialize_ex//.........这里部分代码省略......... BG(serialize_lock)++; ce = zend_lookup_class(class_name); if (ce) { BG(serialize_lock)--; if (EG(exception)) { zend_string_release(class_name); return 0; } break; } BG(serialize_lock)--; if (EG(exception)) { zend_string_release(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 */ ZVAL_STRING(&user_func, PG(unserialize_callback_func)); ZVAL_STR_COPY(&args[0], class_name); BG(serialize_lock)++; if (call_user_function_ex(CG(function_table), NULL, &user_func, &retval, 1, args, 0, NULL) != SUCCESS) { BG(serialize_lock)--; if (EG(exception)) { zend_string_release(class_name); zval_ptr_dtor(&user_func); zval_ptr_dtor(&args[0]); return 0; } php_error_docref(NULL, E_WARNING, "defined (%s) but not found", Z_STRVAL(user_func)); incomplete_class = 1; ce = PHP_IC_ENTRY; zval_ptr_dtor(&user_func); zval_ptr_dtor(&args[0]); break; } BG(serialize_lock)--; zval_ptr_dtor(&retval); if (EG(exception)) { zend_string_release(class_name); zval_ptr_dtor(&user_func); zval_ptr_dtor(&args[0]); return 0; } /* The callback function may have defined the class */ if ((ce = zend_lookup_class(class_name)) == NULL) { php_error_docref(NULL, E_WARNING, "Function %s() hasn't defined the class it was called for", Z_STRVAL(user_func)); incomplete_class = 1; ce = PHP_IC_ENTRY; } zval_ptr_dtor(&user_func); zval_ptr_dtor(&args[0]); break; } while (1); *p = YYCURSOR;
开发者ID:Freeaqingme,项目名称:php-src,代码行数:67,
示例18: qb_transfer_value_from_import_sourcestatic int32_t qb_transfer_value_from_import_source(qb_interpreter_context *cxt, qb_variable *ivar, qb_import_scope *scope) { int32_t result = TRUE; if(!(ivar->flags & QB_VARIABLE_IMPORTED)) { USE_TSRM zval *zvalue = NULL, **p_zvalue = NULL; if(ivar->value_pointer) { p_zvalue = ivar->value_pointer; Z_ADDREF_PP(p_zvalue); } else { switch(scope->type) { case QB_IMPORT_SCOPE_GLOBAL: case QB_IMPORT_SCOPE_LEXICAL: { // copy value from symbol table if(zend_hash_quick_find(scope->symbol_table, ivar->name, ivar->name_length + 1, ivar->hash_value, (void **) &p_zvalue) == SUCCESS) { SEPARATE_ZVAL_TO_MAKE_IS_REF(p_zvalue); } } break; case QB_IMPORT_SCOPE_CLASS: { if(ivar->flags & QB_VARIABLE_CLASS_CONSTANT) { // static:: constants are treated like variables zend_class_entry *ce = scope->zend_class; zval **p_value; zend_hash_quick_find(&ce->constants_table, ivar->name, ivar->name_length + 1, ivar->hash_value, (void **) &p_value); } else { zend_class_entry *ce = scope->zend_class; p_zvalue = Z_CLASS_GET_PROP(ce, ivar->name, ivar->name_length); if(p_zvalue) { SEPARATE_ZVAL_TO_MAKE_IS_REF(p_zvalue); } } } break; case QB_IMPORT_SCOPE_OBJECT: { // copy value from class instance zval *name = qb_string_to_zval(ivar->name, ivar->name_length TSRMLS_CC); zval *container = scope->zend_object; p_zvalue = Z_OBJ_GET_PROP_PTR_PTR(container, name); if(p_zvalue) { SEPARATE_ZVAL_TO_MAKE_IS_REF(p_zvalue); } else if(Z_OBJ_HT_P(container)->read_property) { zvalue = Z_OBJ_READ_PROP(container, name); Z_ADDREF_P(zvalue); } } break; default: { } break; } } if(p_zvalue) { zvalue = *p_zvalue; } if(zvalue) { if(!qb_transfer_value_from_zval(scope->storage, ivar->address, zvalue, QB_TRANSFER_CAN_BORROW_MEMORY | QB_TRANSFER_CAN_AUTOVIVIFICATE)) { uint32_t line_id = qb_get_zend_line_id(TSRMLS_C); qb_set_exception_line_id(line_id TSRMLS_CC); result = FALSE; } } else { if(!qb_transfer_value_from_zval(scope->storage, ivar->address, &zval_used_for_init, QB_TRANSFER_CAN_BORROW_MEMORY | QB_TRANSFER_CAN_AUTOVIVIFICATE)) { uint32_t line_id = qb_get_zend_line_id(TSRMLS_C); qb_set_exception_line_id(line_id TSRMLS_CC); result = FALSE; } } ivar->flags |= QB_VARIABLE_IMPORTED; ivar->value_pointer = p_zvalue; if(ivar->value) { zval_ptr_dtor(&ivar->value); } ivar->value = zvalue; } return result;}
开发者ID:remicollet,项目名称:qb,代码行数:72,
示例19: oauth_provider_parse_auth_headerstatic int oauth_provider_parse_auth_header(php_oauth_provider *sop, char *auth_header) /* {{{ */{ pcre_cache_entry *pce; zval subpats, return_value, *item_param, *current_param, *current_val; HashPosition hpos; zend_string *regex = zend_string_init(OAUTH_REGEX, sizeof(OAUTH_REGEX) - 1, 0); size_t decoded_len; if(!auth_header || strncasecmp(auth_header, "oauth", 4) || !sop) { return FAILURE; } /* pass "OAuth " */ auth_header += 5; if ((pce = pcre_get_compiled_regex_cache(regex)) == NULL) { zend_string_release(regex); return FAILURE; } zend_string_release(regex); ZVAL_NULL(&subpats); ZVAL_NULL(&return_value); php_pcre_match_impl( pce, auth_header, strlen(auth_header), &return_value, &subpats, 1, /* global */ 1, /* use flags */ 2, /* PREG_SET_ORDER */ 0 ); if (0 == Z_LVAL(return_value)) { return FAILURE; } zend_hash_internal_pointer_reset_ex(Z_ARRVAL(subpats), &hpos); /* walk the oauth param names */ do { if ((item_param = zend_hash_get_current_data_ex(Z_ARRVAL(subpats), &hpos)) != NULL) { zval decoded_val; char *tmp; /* * item = array( * 1 => param name * 2 => quoted value * 3 => unquoted value (defined if matched) * ) */ current_param = zend_hash_index_find(Z_ARRVAL_P(item_param), 1); if ((current_val =zend_hash_index_find(Z_ARRVAL_P(item_param), 3)) == NULL) { current_val = zend_hash_index_find(Z_ARRVAL_P(item_param), 2); } tmp = estrndup(Z_STRVAL_P(current_val), Z_STRLEN_P(current_val)); decoded_len = php_url_decode(tmp, Z_STRLEN_P(current_val)); ZVAL_STRINGL(&decoded_val, tmp, decoded_len); if (oauth_provider_set_param_value(sop->oauth_params, Z_STRVAL_P(current_param), &decoded_val)==FAILURE) { return FAILURE; } Z_DELREF(decoded_val); } } while (SUCCESS==zend_hash_move_forward_ex(Z_ARRVAL(subpats), &hpos)); zval_ptr_dtor(&return_value); zval_ptr_dtor(&subpats); return SUCCESS;}
开发者ID:keyurdg,项目名称:pecl-web_services-oauth,代码行数:74,
示例20: do_cli//.........这里部分代码省略......... case PHP_MODE_REFLECTION_EXTENSION: case PHP_MODE_REFLECTION_ZEND_EXTENSION: { zend_class_entry *pce = NULL; zval arg, ref; zend_execute_data execute_data; switch (behavior) { default: break; case PHP_MODE_REFLECTION_FUNCTION: if (strstr(reflection_what, "::")) { pce = reflection_method_ptr; } else { pce = reflection_function_ptr; } break; case PHP_MODE_REFLECTION_CLASS: pce = reflection_class_ptr; break; case PHP_MODE_REFLECTION_EXTENSION: pce = reflection_extension_ptr; break; case PHP_MODE_REFLECTION_ZEND_EXTENSION: pce = reflection_zend_extension_ptr; break; } ZVAL_STRING(&arg, reflection_what); object_init_ex(&ref, pce); memset(&execute_data, 0, sizeof(zend_execute_data)); EG(current_execute_data) = &execute_data; zend_call_method_with_1_params(&ref, pce, &pce->constructor, "__construct", NULL, &arg); if (EG(exception)) { zval tmp, *msg, rv; ZVAL_OBJ(&tmp, EG(exception)); msg = zend_read_property(zend_ce_exception, &tmp, "message", sizeof("message")-1, 0, &rv); zend_printf("Exception: %s/n", Z_STRVAL_P(msg)); zval_ptr_dtor(&tmp); EG(exception) = NULL; } else { zend_call_method_with_1_params(NULL, reflection_ptr, NULL, "export", NULL, &ref); } zval_ptr_dtor(&ref); zval_ptr_dtor(&arg); break; } case PHP_MODE_REFLECTION_EXT_INFO: { int len = (int)strlen(reflection_what); char *lcname = zend_str_tolower_dup(reflection_what, len); zend_module_entry *module; if ((module = zend_hash_str_find_ptr(&module_registry, lcname, len)) == NULL) { if (!strcmp(reflection_what, "main")) { display_ini_entries(NULL); } else { zend_printf("Extension '%s' not present./n", reflection_what); exit_status = 1; } } else { php_info_print_module(module); } efree(lcname); break; } case PHP_MODE_SHOW_INI_CONFIG: { zend_printf("Configuration File (php.ini) Path: %s/n", PHP_CONFIG_FILE_PATH); zend_printf("Loaded Configuration File: %s/n", php_ini_opened_path ? php_ini_opened_path : "(none)"); zend_printf("Scan for additional .ini files in: %s/n", php_ini_scanned_path ? php_ini_scanned_path : "(none)"); zend_printf("Additional .ini files parsed: %s/n", php_ini_scanned_files ? php_ini_scanned_files : "(none)"); break; } } } zend_end_try();out: if (request_started) { php_request_shutdown((void *) 0); } if (translated_path) { free(translated_path); } if (exit_status == 0) { exit_status = EG(exit_status); } return exit_status;err: sapi_deactivate(); zend_ini_deactivate(); exit_status = 1; goto out;}
开发者ID:EleTeam,项目名称:php-src,代码行数:101,
示例21: php_mongo_enumerate_collectionsstatic void php_mongo_enumerate_collections(INTERNAL_FUNCTION_PARAMETERS, int full_collection){ zend_bool system_col = 0; zval *nss, *collection, *cursor, *list, *next; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &system_col) == FAILURE) { return; } // select db.system.namespaces collection MAKE_STD_ZVAL(nss); ZVAL_STRING(nss, "system.namespaces", 1); MAKE_STD_ZVAL(collection); MONGO_METHOD1(MongoDB, selectCollection, collection, getThis(), nss); // list to return MAKE_STD_ZVAL(list); array_init(list); // do find MAKE_STD_ZVAL(cursor); MONGO_METHOD(MongoCollection, find, cursor, collection); // populate list MAKE_STD_ZVAL(next); MONGO_METHOD(MongoCursor, getNext, next, cursor); while (!IS_SCALAR_P(next)) { zval *c, *zname; zval **collection; char *name, *first_dot, *system; // check that the ns is valid and not an index (contains $) if (zend_hash_find(HASH_P(next), "name", 5, (void**)&collection) == FAILURE || strchr(Z_STRVAL_PP(collection), '$')) { zval_ptr_dtor(&next); MAKE_STD_ZVAL(next); ZVAL_NULL(next); MONGO_METHOD(MongoCursor, getNext, next, cursor); continue; } first_dot = strchr(Z_STRVAL_PP(collection), '.'); system = strstr(Z_STRVAL_PP(collection), ".system."); // check that this isn't a system ns if (!system_col && (system && first_dot == system) || (name = strchr(Z_STRVAL_PP(collection), '.')) == 0) { zval_ptr_dtor(&next); MAKE_STD_ZVAL(next); ZVAL_NULL(next); MONGO_METHOD(MongoCursor, getNext, next, cursor); continue; } // take a substring after the first "." name++; // "foo." was allowed in earlier versions if (name == '/0') { zval_ptr_dtor(&next); MAKE_STD_ZVAL(next); ZVAL_NULL(next); MONGO_METHOD(MongoCursor, getNext, next, cursor); continue; } if (full_collection) { MAKE_STD_ZVAL(c); ZVAL_NULL(c); MAKE_STD_ZVAL(zname); ZVAL_NULL(zname); // name must be copied because it is a substring of // a string that will be garbage collected in a sec ZVAL_STRING(zname, name, 1); MONGO_METHOD1(MongoDB, selectCollection, c, getThis(), zname); add_next_index_zval(list, c); zval_ptr_dtor(&zname); } else { add_next_index_string(list, name, 1); } zval_ptr_dtor(&next); MAKE_STD_ZVAL(next); MONGO_METHOD(MongoCursor, getNext, next, cursor); } zval_ptr_dtor(&next); zval_ptr_dtor(&nss); zval_ptr_dtor(&cursor); zval_ptr_dtor(&collection);//.........这里部分代码省略.........
开发者ID:cockatoo-org,项目名称:mongo-php-driver,代码行数:101,
示例22: php_filter_intvoid php_filter_int(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */{ zval *option_val; zend_long min_range, max_range, option_flags; int min_range_set, max_range_set; int allow_octal = 0, allow_hex = 0; size_t len; int error = 0; zend_long ctx_value; char *p; /* Parse options */ FETCH_LONG_OPTION(min_range, "min_range"); FETCH_LONG_OPTION(max_range, "max_range"); option_flags = flags; len = Z_STRLEN_P(value); if (len == 0) { RETURN_VALIDATION_FAILED } if (option_flags & FILTER_FLAG_ALLOW_OCTAL) { allow_octal = 1; } if (option_flags & FILTER_FLAG_ALLOW_HEX) { allow_hex = 1; } /* Start the validating loop */ p = Z_STRVAL_P(value); ctx_value = 0; PHP_FILTER_TRIM_DEFAULT(p, len); if (*p == '0') { p++; len--; if (allow_hex && (*p == 'x' || *p == 'X')) { p++; len--; if (php_filter_parse_hex(p, len, &ctx_value) < 0) { error = 1; } } else if (allow_octal) { if (php_filter_parse_octal(p, len, &ctx_value) < 0) { error = 1; } } else if (len != 0) { error = 1; } } else { if (php_filter_parse_int(p, len, &ctx_value) < 0) { error = 1; } } if (error > 0 || (min_range_set && (ctx_value < min_range)) || (max_range_set && (ctx_value > max_range))) { RETURN_VALIDATION_FAILED } else { zval_ptr_dtor(value); ZVAL_LONG(value, ctx_value); return; }}
开发者ID:ChadSikorra,项目名称:php-src,代码行数:64,
示例23: php_sscanf_internal//.........这里部分代码省略......... format = end+1; ch = format++; objIndex = varStart + value - 1; } } /* * Parse any width specifier. */ if ( isdigit(UCHAR(*ch))) { width = ZEND_STRTOUL(format-1, &format, 10); ch = format++; } else { width = 0; } /* * Ignore size specifier. */ if ((*ch == 'l') || (*ch == 'L') || (*ch == 'h')) { ch = format++; } /* * Handle the various field types. */ switch (*ch) { case 'n': if (!(flags & SCAN_SUPPRESS)) { if (numVars && objIndex >= argCount) { break; } else if (numVars) { current = Z_REFVAL(args[objIndex++]); zval_ptr_dtor(current); ZVAL_LONG(current, (zend_long)(string - baseString) ); } else { add_index_long(return_value, objIndex++, string - baseString); } } nconversions++; continue; case 'd': case 'D': op = 'i'; base = 10; fn = (zend_long (*)())ZEND_STRTOL_PTR; break; case 'i': op = 'i'; base = 0; fn = (zend_long (*)())ZEND_STRTOL_PTR; break; case 'o': op = 'i'; base = 8; fn = (zend_long (*)())ZEND_STRTOL_PTR; break; case 'x': case 'X': op = 'i'; base = 16; fn = (zend_long (*)())ZEND_STRTOL_PTR; break; case 'u': op = 'i';
开发者ID:13572293130,项目名称:php-src,代码行数:67,
示例24: yaf_route_pathinfo_route//.........这里部分代码省略......... char *uri; if (req_uri_len == 0 || (req_uri_len == 1 && *req_uri == '/')) { break; } uri = req_uri; s = p = uri; q = req_uri + req_uri_len - 1; while (*q == ' ' || *q == '/') { *q-- = '/0'; } strip_slashs(p); if ((s = strstr(p, "/")) != NULL) { if (yaf_application_is_module_name(p, s-p TSRMLS_CC)) { module = estrndup(p, s - p); p = s + 1; strip_slashs(p); if ((s = strstr(p, "/")) != NULL) { controller = estrndup(p, s - p); p = s + 1; } } else { controller = estrndup(p, s - p); p = s + 1; } } strip_slashs(p); if ((s = strstr(p, "/")) != NULL) { action = estrndup(p, s - p); p = s + 1; } strip_slashs(p); if (*p != '/0') { do { if (!module && !controller && !action) { if (yaf_application_is_module_name(p, strlen(p) TSRMLS_CC)) { module = estrdup(p); break; } } if (!controller) { controller = estrdup(p); break; } if (!action) { action = estrdup(p); break; } rest = estrdup(p); } while (0); } if (module && controller == NULL) { controller = module; module = NULL; } else if (module && action == NULL) { action = controller; controller = module; module = NULL; } else if (controller && action == NULL ) { /* /controller */ if (YAF_G(action_prefer)) { action = controller; controller = NULL; } } } while (0); if (module != NULL) { zend_update_property_string(yaf_request_ce, request, ZEND_STRL(YAF_REQUEST_PROPERTY_NAME_MODULE), module TSRMLS_CC); efree(module); } if (controller != NULL) { zend_update_property_string(yaf_request_ce, request, ZEND_STRL(YAF_REQUEST_PROPERTY_NAME_CONTROLLER), controller TSRMLS_CC); efree(controller); } if (action != NULL) { zend_update_property_string(yaf_request_ce, request, ZEND_STRL(YAF_REQUEST_PROPERTY_NAME_ACTION), action TSRMLS_CC); efree(action); } if (rest) { params = yaf_router_parse_parameters(rest TSRMLS_CC); (void)yaf_request_set_params_multi(request, params TSRMLS_CC); zval_ptr_dtor(¶ms); efree(rest); }}
开发者ID:suissa,项目名称:php-yaf,代码行数:101,
示例25: cpManagerReloadstatic void cpManagerReload(int sig){ zval *group_conf = NULL, **v; group_conf = cpGetConfig(CPGC.ini_file); int gid = 0; zval **gid_ptr = NULL; cpGroup *G = NULL; if (!Z_BVAL_P(group_conf)) { cpLog("parse ini file[%s] reload error!", CPGC.ini_file); } else { for (zend_hash_internal_pointer_reset(Z_ARRVAL_P(group_conf)); zend_hash_has_more_elements(Z_ARRVAL_P(group_conf)) == SUCCESS; zend_hash_move_forward(Z_ARRVAL_P(group_conf))) { zval **config; zend_hash_get_current_data(Z_ARRVAL_P(group_conf), (void**) &config); char *name; uint keylen; zend_hash_get_current_key_ex(Z_ARRVAL_P(group_conf), &name, &keylen, NULL, 0, NULL); if (strcmp(name, "common") != 0) { if (zend_hash_find(Z_ARRVAL_P(CPGS->group), name, strlen(name) + 1, (void **) &gid_ptr) == SUCCESS) { gid = Z_LVAL_PP(gid_ptr); G = &CPGS->G[gid]; } else { cpLog("can not add datasource when the server runing,if you want add it please restart"); return; } if (pthread_mutex_lock(G->mutex_lock) == 0) { if (zend_hash_find(Z_ARRVAL_PP(config), ZEND_STRS("pool_max"), (void **) &v) == SUCCESS) { convert_to_long(*v); G->worker_max = (int) Z_LVAL_PP(v); } if (zend_hash_find(Z_ARRVAL_PP(config), ZEND_STRS("pool_min"), (void **) &v) == SUCCESS) { convert_to_long(*v); int new_min = (int) Z_LVAL_PP(v); if (new_min > G->worker_min) {//增加最小 while (G->worker_num < new_min) { cpCreate_worker_mem(G->worker_num, gid); G->workers_status[G->worker_num] = CP_WORKER_IDLE; G->worker_num++; //先加 线程安全 int new_pid = cpFork_one_worker(G->worker_num - 1, gid); if (new_pid < 0) { cpLog("Fork worker process failed. Error: %s [%d]", strerror(errno), errno); } else { G->workers[G->worker_num - 1].pid = new_pid; } } } G->worker_min = new_min; } if (pthread_mutex_unlock(G->mutex_lock) != 0) { cpLog("pthread_mutex_unlock. Error: %s [%d]", strerror(errno), errno); } } } else { if (zend_hash_find(Z_ARRVAL_PP(config), ZEND_STRS("recycle_num"), (void **) &v) == SUCCESS) { convert_to_long(*v); CPGC.recycle_num = (int) Z_LVAL_PP(v); } if (zend_hash_find(Z_ARRVAL_PP(config), ZEND_STRS("idel_time"), (void **) &v) == SUCCESS) { convert_to_long(*v); CPGC.idel_time = (int) Z_LVAL_PP(v); } } } zval_ptr_dtor(&group_conf); }}
开发者ID:caoge,项目名称:php-cp,代码行数:88,
示例26: msgpack_convert_arrayint msgpack_convert_array(zval *return_value, zval *tpl, zval **value){ TSRMLS_FETCH(); if (Z_TYPE_P(tpl) == IS_ARRAY) { char *key; uint key_len; int key_type; ulong key_index; zval **data, **arydata; HashPosition pos, valpos; HashTable *ht, *htval; int num; ht = HASH_OF(tpl); // TODO: maybe need to release memory? array_init(return_value); num = zend_hash_num_elements(ht); if (num <= 0) { MSGPACK_WARNING( "[msgpack] (%s) template array length is 0", __FUNCTION__); zval_ptr_dtor(value); return FAILURE; } /* string */ if (ht->nNumOfElements != ht->nNextFreeElement) { htval = HASH_OF(*value); if (!htval) { MSGPACK_WARNING( "[msgpack] (%s) input data is not array", __FUNCTION__); zval_ptr_dtor(value); return FAILURE; } zend_hash_internal_pointer_reset_ex(ht, &pos); zend_hash_internal_pointer_reset_ex(htval, &valpos); for (;; zend_hash_move_forward_ex(ht, &pos), zend_hash_move_forward_ex(htval, &valpos)) { key_type = zend_hash_get_current_key_ex( ht, &key, &key_len, &key_index, 0, &pos); if (key_type == HASH_KEY_NON_EXISTANT) { break; } if (zend_hash_get_current_data_ex( ht, (void *)&data, &pos) != SUCCESS) { continue; } if (key_type == HASH_KEY_IS_STRING) { int (*convert_function)(zval *, zval *, zval **) = NULL; zval **dataval, *val; switch (Z_TYPE_PP(data)) { case IS_ARRAY: convert_function = msgpack_convert_array; break; case IS_OBJECT: // case IS_STRING: convert_function = msgpack_convert_object; break; default: break; } if (zend_hash_get_current_data_ex( htval, (void *)&dataval, &valpos) != SUCCESS) { MSGPACK_WARNING( "[msgpack] (%s) can't get data", __FUNCTION__); zval_ptr_dtor(value); return FAILURE; } MSGPACK_CONVERT_COPY_ZVAL(val, dataval); if (convert_function) { zval *rv; ALLOC_INIT_ZVAL(rv); if (convert_function(rv, *data, &val) != SUCCESS) { zval_ptr_dtor(&val); return FAILURE; }//.........这里部分代码省略.........
开发者ID:LoosKonstantin,项目名称:msgpack,代码行数:101,
示例27: 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); } /* A fatal error / die occured during the generator execution. Trying to clean * up the stack may not be safe in this case. */ if (CG(unclean_shutdown)) { return; } /* 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 **ptr = generator->stack->top - 1; void **end = zend_vm_stack_frame_base(execute_data); /* If the top stack element is the argument count, skip it */ if (execute_data->function_state.arguments) { ptr--; } for (; ptr >= end; --ptr) { zval_ptr_dtor((zval**) ptr); } } 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;//.........这里部分代码省略.........
开发者ID:RozeDoyanawa,项目名称:php-src,代码行数:101,
示例28: msgpack_convert_objectint msgpack_convert_object(zval *return_value, zval *tpl, zval **value){ zend_class_entry *ce, **pce; TSRMLS_FETCH(); switch (Z_TYPE_P(tpl)) { case IS_STRING: if (zend_lookup_class( Z_STRVAL_P(tpl), Z_STRLEN_P(tpl), &pce TSRMLS_CC) != SUCCESS) { MSGPACK_ERROR("[msgpack] (%s) Class '%s' not found", __FUNCTION__, Z_STRVAL_P(tpl)); return FAILURE; } ce = *pce; break; case IS_OBJECT: ce = zend_get_class_entry(tpl TSRMLS_CC); break; default: MSGPACK_ERROR("[msgpack] (%s) object type is unsupported", __FUNCTION__); return FAILURE; } if (Z_TYPE_PP(value) == IS_OBJECT) { zend_class_entry *vce; vce = zend_get_class_entry(*value TSRMLS_CC); if (strcmp(ce->name, vce->name) == 0) { *return_value = **value; zval_copy_ctor(return_value); zval_ptr_dtor(value); return SUCCESS; } } object_init_ex(return_value, ce); /* Run the constructor if there is one */ if (ce->constructor && (ce->constructor->common.fn_flags & ZEND_ACC_PUBLIC)) { zval *retval_ptr = NULL; zval ***params = NULL; int num_args = 0; zend_fcall_info fci; zend_fcall_info_cache fcc;#if ZEND_MODULE_API_NO >= 20090626 fci.size = sizeof(fci); fci.function_table = EG(function_table); fci.function_name = NULL; fci.symbol_table = NULL; fci.object_ptr = return_value; fci.retval_ptr_ptr = &retval_ptr; fci.param_count = num_args; fci.params = params; fci.no_separation = 1; fcc.initialized = 1; fcc.function_handler = ce->constructor; fcc.calling_scope = EG(scope); fcc.called_scope = Z_OBJCE_P(return_value); fcc.object_ptr = return_value;#else fci.size = sizeof(fci); fci.function_table = EG(function_table); fci.function_name = NULL; fci.symbol_table = NULL; fci.object_pp = &return_value; fci.retval_ptr_ptr = &retval_ptr; fci.param_count = num_args; fci.params = params; fci.no_separation = 1; fcc.initialized = 1; fcc.function_handler = ce->constructor; fcc.calling_scope = EG(scope); fcc.object_pp = &return_value;#endif if (zend_call_function(&fci, &fcc TSRMLS_CC) == FAILURE) { if (params) { efree(params); } if (retval_ptr) { zval_ptr_dtor(&retval_ptr); } MSGPACK_WARNING( "[msgpack] (%s) Invocation of %s's constructor failed", __FUNCTION__, ce->name);//.........这里部分代码省略.........
开发者ID:LoosKonstantin,项目名称:msgpack,代码行数:101,
注:本文中的zval_ptr_dtor函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ A类代码示例 C++ zval_get_string函数代码示例 |