您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ ALLOC_HASHTABLE函数代码示例

51自学网 2021-06-01 19:34:43
  C++
这篇教程C++ ALLOC_HASHTABLE函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中ALLOC_HASHTABLE函数的典型用法代码示例。如果您正苦于以下问题:C++ ALLOC_HASHTABLE函数的具体用法?C++ ALLOC_HASHTABLE怎么用?C++ ALLOC_HASHTABLE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了ALLOC_HASHTABLE函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: PHP_RINIT_FUNCTION

static PHP_RINIT_FUNCTION(protobuf) {  ALLOC_HASHTABLE(upb_def_to_php_obj_map);  zend_hash_init(upb_def_to_php_obj_map, 16, NULL, ZVAL_PTR_DTOR, 0);  ALLOC_HASHTABLE(ce_to_php_obj_map);  zend_hash_init(ce_to_php_obj_map, 16, NULL, ZVAL_PTR_DTOR, 0);  generated_pool = NULL;  generated_pool_php = NULL;}
开发者ID:maniacs-ops,项目名称:protobuf,代码行数:10,


示例2: _hprose_class_manager_register

void _hprose_class_manager_register(char *name, int32_t nlen, char *alias, int32_t alen TSRMLS_DC) {    hprose_bytes_io *_name = hprose_bytes_io_create(name, nlen);    hprose_bytes_io *_alias = hprose_bytes_io_create(alias, alen);    if (!HPROSE_G(cache1)) {        ALLOC_HASHTABLE(HPROSE_G(cache1));        zend_hash_init(HPROSE_G(cache1), 64, NULL, hprose_bytes_io_dtor, 0);    }    if (!HPROSE_G(cache2)) {        ALLOC_HASHTABLE(HPROSE_G(cache2));        zend_hash_init(HPROSE_G(cache2), 64, NULL, hprose_bytes_io_dtor, 0);    }    zend_hash_str_update_ptr(HPROSE_G(cache1), name, nlen, _alias);    zend_hash_str_update_ptr(HPROSE_G(cache2), alias, alen, _name);}
开发者ID:hakiu,项目名称:hprose-pecl,代码行数:14,


示例3: ALLOC_HASHTABLE

static HashTable *browscap_entry_to_array(browser_data *bdata, browscap_entry *entry) {	zval tmp;	uint32_t i;	HashTable *ht;	ALLOC_HASHTABLE(ht);	zend_hash_init(ht, 8, NULL, ZVAL_PTR_DTOR, 0);	ZVAL_STR(&tmp, browscap_convert_pattern(entry->pattern, 0));	zend_hash_str_add(ht, "browser_name_regex", sizeof("browser_name_regex")-1, &tmp);	ZVAL_STR_COPY(&tmp, entry->pattern);	zend_hash_str_add(ht, "browser_name_pattern", sizeof("browser_name_pattern")-1, &tmp);	if (entry->parent) {		ZVAL_STR_COPY(&tmp, entry->parent);		zend_hash_str_add(ht, "parent", sizeof("parent")-1, &tmp);	}	for (i = entry->kv_start; i < entry->kv_end; i++) {		ZVAL_STR_COPY(&tmp, bdata->kv[i].value);		zend_hash_add(ht, bdata->kv[i].key, &tmp);	}	return ht;}
开发者ID:Synchro,项目名称:php-src,代码行数:26,


示例4: msgfmt_do_format

/* {{{ */static void msgfmt_do_format(MessageFormatter_object *mfo, zval *args, zval *return_value){	int count;	UChar* formatted = NULL;	int formatted_len = 0;	HashTable *args_copy;	count = zend_hash_num_elements(Z_ARRVAL_P(args));	ALLOC_HASHTABLE(args_copy);	zend_hash_init(args_copy, count, NULL, ZVAL_PTR_DTOR, 0);	zend_hash_copy(args_copy, Z_ARRVAL_P(args), (copy_ctor_func_t)zval_add_ref);	umsg_format_helper(mfo, args_copy, &formatted, &formatted_len);	zend_hash_destroy(args_copy);	efree(args_copy);	if (formatted && U_FAILURE(INTL_DATA_ERROR_CODE(mfo))) {			efree(formatted);	}	if (U_FAILURE(INTL_DATA_ERROR_CODE(mfo))) {		RETURN_FALSE;	} else {		INTL_METHOD_RETVAL_UTF8(mfo, formatted, formatted_len, 1);	}}
开发者ID:AmesianX,项目名称:php-src,代码行数:29,


示例5: ZEND_ASSERT

static inline zend_long *pthreads_get_guard(zend_object *zobj, zval *member) /* {{{ */{    HashTable *guards;    zend_long stub, *guard;    zval tmp;    ZEND_ASSERT(GC_FLAGS(zobj) & IS_OBJ_USE_GUARDS);    if (GC_FLAGS(zobj) & IS_OBJ_HAS_GUARDS) {        guards = Z_PTR(zobj->properties_table[zobj->ce->default_properties_count]);        ZEND_ASSERT(guards != NULL);		if (Z_TYPE_P(member) == IS_LONG) {			if ((guard = (zend_long *)zend_hash_index_find_ptr(guards, Z_LVAL_P(member))) != NULL) {            	return guard;        	}		} else {			if ((guard = (zend_long *)zend_hash_find_ptr(guards, Z_STR_P(member))) != NULL) {            	return guard;        	}		}            } else {        ALLOC_HASHTABLE(guards);        zend_hash_init(guards, 8, NULL, pthreads_guard_dtor, 0);        ZVAL_PTR(&tmp, guards);        Z_PTR(zobj->properties_table[zobj->ce->default_properties_count]) = guards;        GC_FLAGS(zobj) |= IS_OBJ_HAS_GUARDS;    }    stub = 0;	if (Z_TYPE_P(member) == IS_LONG) {		return (zend_long *)zend_hash_index_add_mem(guards, Z_LVAL_P(member), &stub, sizeof(zend_ulong));	} else return (zend_long *)zend_hash_add_mem(guards, Z_STR_P(member), &stub, sizeof(zend_ulong));}
开发者ID:MHelius,项目名称:pthreads,代码行数:33,


示例6: luasandbox_timer_enable_profiler

int luasandbox_timer_enable_profiler(luasandbox_timer_set * lts, struct timespec * period){	if (lts->profiler_running) {		luasandbox_timer_stop_one(lts->profiler_timer, NULL);		lts->profiler_running = 0;	}	lts->profiler_period = *period;	if (lts->function_counts) {		zend_hash_destroy(lts->function_counts);		FREE_HASHTABLE(lts->function_counts);		lts->function_counts = NULL;	}	lts->total_count = 0;	lts->overrun_count = 0;	if (period->tv_sec || period->tv_nsec) {		ALLOC_HASHTABLE(lts->function_counts);		zend_hash_init(lts->function_counts, 0, NULL, NULL, 0);		luasandbox_timer * timer = luasandbox_timer_create_one(			lts->sandbox, LUASANDBOX_TIMER_PROFILER);		if (!timer) {			return 0;		}		lts->profiler_running = 1;		lts->profiler_timer = timer;		luasandbox_timer_set_periodic(timer, &lts->profiler_period);	}	return 1;}
开发者ID:wikimedia,项目名称:mediawiki-php-luasandbox,代码行数:28,


示例7: switch

/* {{{ php_oci_lob_create() Create LOB descriptor and allocate all the resources needed */php_oci_descriptor *php_oci_lob_create (php_oci_connection *connection, long type TSRMLS_DC){	php_oci_descriptor *descriptor;	switch (type) {		case OCI_DTYPE_FILE:		case OCI_DTYPE_LOB:		case OCI_DTYPE_ROWID:			/* these three are allowed */			break;		default:			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown descriptor type %ld", type);			return NULL;			break;	}	descriptor = ecalloc(1, sizeof(php_oci_descriptor));	descriptor->type = type;	descriptor->connection = connection;	zend_list_addref(descriptor->connection->rsrc_id);	PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIDescriptorAlloc, (connection->env, (dvoid*)&(descriptor->descriptor), descriptor->type, (size_t) 0, (dvoid **) 0));	if (OCI_G(errcode) != OCI_SUCCESS) {		OCI_G(errcode) = php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC);		PHP_OCI_HANDLE_ERROR(connection, OCI_G(errcode));		efree(descriptor);		return NULL;	}	PHP_OCI_REGISTER_RESOURCE(descriptor, le_descriptor);		descriptor->lob_current_position = 0;	descriptor->lob_size = -1;				/* we should set it to -1 to know, that it's just not initialized */	descriptor->buffering = PHP_OCI_LOB_BUFFER_DISABLED;				/* buffering is off by default */	descriptor->charset_form = SQLCS_IMPLICIT;	/* default value */	descriptor->charset_id = connection->charset;	descriptor->is_open = 0;	if (descriptor->type == OCI_DTYPE_LOB || descriptor->type == OCI_DTYPE_FILE) {		/* add Lobs & Files to hash. we'll flush them at the end */		if (!connection->descriptors) {			ALLOC_HASHTABLE(connection->descriptors);			zend_hash_init(connection->descriptors, 0, NULL, php_oci_descriptor_flush_hash_dtor, 0);			connection->descriptor_count = 0;		}				descriptor->index = (connection->descriptor_count)++;		if (connection->descriptor_count == LONG_MAX) {			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Internal descriptor counter has reached limit");			php_oci_connection_descriptors_free(connection TSRMLS_CC);			return NULL;		}		zend_hash_index_update(connection->descriptors,descriptor->index,&descriptor,sizeof(php_oci_descriptor *),NULL);	}	return descriptor;} /* }}} */
开发者ID:NobleGaz,项目名称:PHP,代码行数:61,


示例8: ecalloc

/* {{{ xsl_objects_new */zend_object *xsl_objects_new(zend_class_entry *class_type){	xsl_object *intern;	intern = ecalloc(1, sizeof(xsl_object) + sizeof(zval) * (class_type->default_properties_count - 1));	intern->securityPrefs = XSL_SECPREF_DEFAULT;	zend_object_std_init(&intern->std, class_type);	object_properties_init(&intern->std, class_type);	ALLOC_HASHTABLE(intern->parameter);	zend_hash_init(intern->parameter, 0, NULL, ZVAL_PTR_DTOR, 0);	ALLOC_HASHTABLE(intern->registered_phpfunctions);	zend_hash_init(intern->registered_phpfunctions, 0, NULL, ZVAL_PTR_DTOR, 0);	intern->std.handlers = &xsl_object_handlers;	return &intern->std;}
开发者ID:AmesianX,项目名称:php-src,代码行数:18,


示例9: ALLOC_HASHTABLE

static HashTable *zend_closure_get_debug_info(zval *object, int *is_temp) /* {{{ */{	zend_closure *closure = (zend_closure *)Z_OBJ_P(object);	zval val;	struct _zend_arg_info *arg_info = closure->func.common.arg_info;	*is_temp = 0;	if (closure->debug_info == NULL) {		ALLOC_HASHTABLE(closure->debug_info);		zend_hash_init(closure->debug_info, 8, NULL, ZVAL_PTR_DTOR, 0);	}	if (closure->debug_info->u.v.nApplyCount == 0) {		if (closure->func.type == ZEND_USER_FUNCTION && closure->func.op_array.static_variables) {			HashTable *static_variables = closure->func.op_array.static_variables;			ZVAL_ARR(&val, zend_array_dup(static_variables));			zend_hash_str_update(closure->debug_info, "static", sizeof("static")-1, &val);		}		if (Z_TYPE(closure->this_ptr) != IS_UNDEF) {			Z_ADDREF(closure->this_ptr);			zend_hash_str_update(closure->debug_info, "this", sizeof("this")-1, &closure->this_ptr);		}		if (arg_info &&		    (closure->func.common.num_args ||		     (closure->func.common.fn_flags & ZEND_ACC_VARIADIC))) {			uint32_t i, num_args, required = closure->func.common.required_num_args;			array_init(&val);			num_args = closure->func.common.num_args;			if (closure->func.common.fn_flags & ZEND_ACC_VARIADIC) {				num_args++;			}			for (i = 0; i < num_args; i++) {				zend_string *name;				zval info;				if (arg_info->name) {					name = zend_strpprintf(0, "%s$%s",							arg_info->pass_by_reference ? "&" : "",							arg_info->name->val);				} else {					name = zend_strpprintf(0, "%s$param%d",							arg_info->pass_by_reference ? "&" : "",							i + 1);				}				ZVAL_NEW_STR(&info, zend_strpprintf(0, "%s", i >= required ? "<optional>" : "<required>"));				zend_hash_update(Z_ARRVAL(val), name, &info);				zend_string_release(name);				arg_info++;			}			zend_hash_str_update(closure->debug_info, "parameter", sizeof("parameter")-1, &val);		}	}	return closure->debug_info;}
开发者ID:Crell,项目名称:php-src,代码行数:58,


示例10: PHP_METHOD

/* {{{ proto void SolrInputDocument::__clone(void)  Clones the current object. Not to be called directly. */PHP_METHOD(SolrInputDocument, __clone){	zval *objptr = getThis();	solr_document_t new_solr_doc;	solr_document_t *new_doc_entry = NULL, *old_doc_entry = NULL;	ulong document_index = SOLR_UNIQUE_DOCUMENT_INDEX();	new_doc_entry = &new_solr_doc;	new_doc_entry = (solr_document_t *) pemalloc(sizeof(solr_document_t), SOLR_DOCUMENT_PERSISTENT);	memset(&new_solr_doc, 0, sizeof(solr_document_t));	/* Retrieve the document entry for the original SolrDocument */	if (solr_fetch_document_entry(objptr, &old_doc_entry TSRMLS_CC) == FAILURE) {		return ;	}	/* Duplicate the doc_entry contents */	memcpy(new_doc_entry, old_doc_entry, sizeof(solr_document_t));	/* Override the document index with a new one and create a new HashTable */	new_doc_entry->document_index = document_index;	/* Allocate new memory for the fields HashTable, using fast cache for HashTables */	ALLOC_HASHTABLE(new_doc_entry->fields);	ALLOC_HASHTABLE(new_doc_entry->children);	/* Initializing the hash table used for storing fields in this SolrDocument */	zend_hash_init(new_doc_entry->fields, old_doc_entry->fields->nTableSize, NULL, (dtor_func_t) solr_destroy_field_list_ht_dtor, SOLR_DOCUMENT_FIELD_PERSISTENT);	zend_hash_init(new_doc_entry->children, old_doc_entry->children->nTableSize, NULL, ZVAL_PTR_DTOR, SOLR_DOCUMENT_FIELD_PERSISTENT);	/* Copy the contents of the old fields HashTable to the new SolrDocument */	zend_hash_copy(new_doc_entry->fields, old_doc_entry->fields, (copy_ctor_func_t) field_copy_constructor);	zend_hash_copy(new_doc_entry->children, old_doc_entry->children, (copy_ctor_func_t) zval_add_ref);	/* Add the document entry to the directory of documents */	zend_hash_index_update_ptr(SOLR_GLOBAL(documents), document_index, (void *) new_doc_entry);	/* Set the value of the internal id property */	zend_update_property_long(solr_ce_SolrInputDocument, objptr, SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) - 1, document_index TSRMLS_CC);	/* Keep track of how many SolrDocument instances we currently have */	SOLR_GLOBAL(document_count)++;}
开发者ID:0mars,项目名称:pecl-search_engine-solr,代码行数:47,


示例11: PHP_METHOD

/* {{{ proto void SolrInputDocument::__construct()	SolrInputDocument constructor */PHP_METHOD(SolrInputDocument, __construct){	zval *objptr = getThis();	uint nSize = SOLR_INITIAL_HASH_TABLE_SIZE;	ulong document_index = SOLR_UNIQUE_DOCUMENT_INDEX();	auto solr_document_t solr_doc;	solr_document_t *doc_entry = NULL, *doc_ptr = NULL;	memset(&solr_doc, 0, sizeof(solr_document_t));	doc_entry = &solr_doc;	doc_entry->document_index  = document_index;	doc_entry->field_count     = 0L;	doc_entry->document_boost  = 0.0f;	/* Allocated memory for the fields HashTable using fast cache for HashTables */	ALLOC_HASHTABLE(doc_entry->fields);	ALLOC_HASHTABLE(doc_entry->children);	/* Initializing the hash table used for storing fields in this SolrDocument */	zend_hash_init(doc_entry->fields, nSize, NULL, (dtor_func_t) solr_destroy_field_list, SOLR_DOCUMENT_FIELD_PERSISTENT);	zend_hash_init(doc_entry->children, nSize, NULL, ZVAL_PTR_DTOR, SOLR_DOCUMENT_FIELD_PERSISTENT);	/* Let's check one more time before insert into the HashTable */	if (zend_hash_index_exists(SOLR_GLOBAL(documents), document_index)) {		pefree(doc_entry->fields, SOLR_DOCUMENT_FIELD_PERSISTENT);		pefree(doc_entry->children, SOLR_DOCUMENT_FIELD_PERSISTENT);		return;	}	/* Add the document entry to the directory of documents */	zend_hash_index_update(SOLR_GLOBAL(documents), document_index, (void *) doc_entry, sizeof(solr_document_t), (void **) &doc_ptr);	/* Set the value of the internal id property */	zend_update_property_long(solr_ce_SolrInputDocument, objptr, SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) - 1, document_index TSRMLS_CC);	/* Keep track of how many SolrDocument instances we currently have */	SOLR_GLOBAL(document_count)++;	/* Overriding the default object handlers */	Z_OBJ_HT_P(objptr) = &solr_input_document_object_handlers;}
开发者ID:cfgxy,项目名称:php-solr,代码行数:47,


示例12: php_stream_filter_register_factory_volatile

/* API for registering VOLATILE wrappers */PHPAPI int php_stream_filter_register_factory_volatile(const char *filterpattern, php_stream_filter_factory *factory){	if (!FG(stream_filters)) {		ALLOC_HASHTABLE(FG(stream_filters));		zend_hash_init(FG(stream_filters), zend_hash_num_elements(&stream_filters_hash), NULL, NULL, 1);		zend_hash_copy(FG(stream_filters), &stream_filters_hash, NULL);	}	return zend_hash_str_add_ptr(FG(stream_filters), (char*)filterpattern, strlen(filterpattern), factory) ? SUCCESS : FAILURE;}
开发者ID:PeeHaa,项目名称:php-src,代码行数:11,


示例13: PHP_METHOD

PHP_METHOD(MIME, load) {	zval *array, *arg, retval;	/* Fetch allowHEAD */	MAKE_STD_ZVAL(array);	array_init_size(array, 2);	add_next_index_stringl(array, "Pancake//Config", sizeof("Pancake//Config") - 1, 1);	add_next_index_stringl(array, "get", 3, 1);	MAKE_STD_ZVAL(arg);	Z_TYPE_P(arg) = IS_STRING;	Z_STRLEN_P(arg) = 4;	Z_STRVAL_P(arg) = estrndup("mime", 4);	call_user_function(CG(function_table), NULL, array, &retval, 1, &arg TSRMLS_CC);	if(Z_TYPE(retval) != IS_ARRAY) {		zend_error(E_ERROR, "Bad MIME type array - Please check Pancake MIME type configuration");	}	ALLOC_HASHTABLE(PANCAKE_GLOBALS(mimeTable));	zend_hash_init(PANCAKE_GLOBALS(mimeTable), 0, NULL, ZVAL_PTR_DTOR, 0);	zval **data, **ext;	char *key;	for(zend_hash_internal_pointer_reset(Z_ARRVAL(retval));		zend_hash_get_current_data(Z_ARRVAL(retval), (void**) &data) == SUCCESS &&		zend_hash_get_current_key(Z_ARRVAL(retval), &key, NULL, 0) == HASH_KEY_IS_STRING;		zend_hash_move_forward(Z_ARRVAL(retval))) {		for(zend_hash_internal_pointer_reset(Z_ARRVAL_PP(data));			zend_hash_get_current_data(Z_ARRVAL_PP(data), (void**) &ext) == SUCCESS;			zend_hash_move_forward(Z_ARRVAL_PP(data))) {			zval *zkey;			MAKE_STD_ZVAL(zkey);			Z_TYPE_P(zkey) = IS_STRING;			Z_STRLEN_P(zkey) = strlen(key);			Z_STRVAL_P(zkey) = estrndup(key, Z_STRLEN_P(zkey));			zend_hash_add(PANCAKE_GLOBALS(mimeTable), Z_STRVAL_PP(ext), Z_STRLEN_PP(ext), (void*) &zkey, sizeof(zval*), NULL);		}	}	MAKE_STD_ZVAL(PANCAKE_GLOBALS(defaultMimeType));	Z_TYPE_P(PANCAKE_GLOBALS(defaultMimeType)) = IS_STRING;	Z_STRLEN_P(PANCAKE_GLOBALS(defaultMimeType)) = sizeof("application/octet-stream") - 1;	Z_STRVAL_P(PANCAKE_GLOBALS(defaultMimeType)) = estrndup("application/octet-stream", sizeof("application/octet-stream") - 1);	free:	zval_dtor(&retval);	zval_ptr_dtor(&array);	zval_ptr_dtor(&arg);}
开发者ID:nhnam,项目名称:Pancake,代码行数:55,


示例14: ALLOC_HASHTABLE

/* {{{ get_debug_info handler for TimeZone */static HashTable *TimeZone_get_debug_info(zval *object, int *is_temp){	zval			zv;	TimeZone_object	*to;	const TimeZone	*tz;	UnicodeString	ustr;	char			*str;	size_t			str_len;	HashTable 		*debug_info;	UErrorCode		uec = U_ZERO_ERROR;	*is_temp = 1;		ALLOC_HASHTABLE(debug_info);	zend_hash_init(debug_info, 8, NULL, ZVAL_PTR_DTOR, 0);	to = Z_INTL_TIMEZONE_P(object);	tz = to->utimezone;	if (tz == NULL) {		ZVAL_FALSE(&zv);		zend_hash_str_update(debug_info, "valid", sizeof("valid") - 1, &zv);		return debug_info;	}	ZVAL_TRUE(&zv);	zend_hash_str_update(debug_info, "valid", sizeof("valid") - 1, &zv);	tz->getID(ustr);	intl_convert_utf16_to_utf8(&str, &str_len,		ustr.getBuffer(), ustr.length(), &uec);	if (U_FAILURE(uec)) {		return debug_info;	}	ZVAL_STRINGL(&zv, str, str_len);	zend_hash_str_update(debug_info, "id", sizeof("id") - 1, &zv);	// TODO: avoid reallocation ???	efree(str);	int32_t rawOffset, dstOffset;	UDate now = Calendar::getNow();	tz->getOffset(now, FALSE, rawOffset, dstOffset, uec);	if (U_FAILURE(uec)) {		return debug_info;	}		ZVAL_LONG(&zv, (zend_long)rawOffset);	zend_hash_str_update(debug_info,"rawOffset", sizeof("rawOffset") - 1, &zv); 	ZVAL_LONG(&zv, (zend_long)(rawOffset + dstOffset));	zend_hash_str_update(debug_info,"currentOffset", sizeof("currentOffset") - 1, &zv); 	return debug_info;}
开发者ID:Tyrael,项目名称:php-src,代码行数:54,


示例15: msgpack_serialize_var_init

void msgpack_serialize_var_init(msgpack_serialize_data_t *var_hash){    HashTable **var_hash_ptr = (HashTable **)var_hash;    TSRMLS_FETCH();    if (MSGPACK_G(serialize).level) {        *var_hash_ptr = MSGPACK_G(serialize).var_hash;    } else {        ALLOC_HASHTABLE(*var_hash_ptr);        zend_hash_init(*var_hash_ptr, 10, NULL, NULL, 0);        MSGPACK_G(serialize).var_hash = *var_hash_ptr;    }    ++MSGPACK_G(serialize).level;}
开发者ID:capcomvertigo,项目名称:msgpack-php,代码行数:14,


示例16: PHP_METHOD

PHP_METHOD(SolrCollapseFunction, __construct){    long int index = SOLR_UNIQUE_FUNCTION_INDEX();    uint nSize = SOLR_INITIAL_HASH_TABLE_SIZE;    solr_function_t *solr_function_dest = NULL;    solr_function_t solr_function;    zval *index_prop, *zvfield = NULL;    solr_char_t *param_name = (solr_char_t *)"field";    int param_name_len = sizeof("field");    solr_string_t field_str;    solr_char_t *field_name = NULL;    int field_name_len = 0;    memset(&solr_function, 0, sizeof(solr_function_t));    if (zend_hash_index_update(SOLR_GLOBAL(functions),index,(void *) &solr_function, sizeof(solr_function_t), (void **) &solr_function_dest) == FAILURE)    {        php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error while registering query parameters in HashTable");        return ;    }    index_prop = zend_read_property(Z_OBJCE_P(getThis()), getThis(), SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) - 1, 1 TSRMLS_CC);    Z_LVAL_P(index_prop) = index;    solr_function_dest->function_index = index;    solr_function_dest->name = (solr_char_t *)"collapse";    solr_function_dest->name_length = sizeof(solr_function_dest->name);    /* Allocated memory for the params HashTable using fast cache for HashTables */    ALLOC_HASHTABLE(solr_function_dest->params);    zend_hash_init(solr_function_dest->params, nSize, NULL, (dtor_func_t) solr_string_free_ex, SOLR_FUNCTIONS_PERSISTENT);    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE)    {        php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error Parsing Parameters");        return;    }    if (field_name_len > 0 ) {        memset(&field_str, 0, sizeof(solr_string_t));        solr_string_set(&field_str, (solr_char_t *)field_name, field_name_len);        if(zend_hash_update(solr_function_dest->params, param_name, param_name_len, (void **)&field_str, sizeof(solr_string_t), NULL) == FAILURE)        {            php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error assigning field");        }    }}
开发者ID:marcosptf,项目名称:pecl-search_engine-solr,代码行数:50,


示例17: _php_array_to_envp

/* {{{ _php_array_to_envp */static php_process_env_t _php_array_to_envp(zval *environment, int is_persistent){	zval *element;	php_process_env_t env;	zend_string *key, *str;#ifndef PHP_WIN32	char **ep;#endif	char *p;	size_t cnt, l, sizeenv = 0;	HashTable *env_hash;	memset(&env, 0, sizeof(env));	if (!environment) {		return env;	}	cnt = zend_hash_num_elements(Z_ARRVAL_P(environment));	if (cnt < 1) {#ifndef PHP_WIN32		env.envarray = (char **) pecalloc(1, sizeof(char *), is_persistent);#endif		env.envp = (char *) pecalloc(4, 1, is_persistent);		return env;	}	ALLOC_HASHTABLE(env_hash);	zend_hash_init(env_hash, cnt, NULL, NULL, 0);	/* first, we have to get the size of all the elements in the hash */	ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(environment), key, element) {		str = zval_get_string(element);		if (ZSTR_LEN(str) == 0) {			zend_string_release(str);			continue;		}		sizeenv += ZSTR_LEN(str) + 1;		if (key && ZSTR_LEN(key)) {			sizeenv += ZSTR_LEN(key) + 1;			zend_hash_add_ptr(env_hash, key, str);		} else {			zend_hash_next_index_insert_ptr(env_hash, str);		}	} ZEND_HASH_FOREACH_END();
开发者ID:AxiosCros,项目名称:php-src,代码行数:50,


示例18: spl_dllist_object_get_debug_info

static HashTable* spl_dllist_object_get_debug_info(zval *obj, int *is_temp) /* {{{{ */{	spl_dllist_object     *intern  = Z_SPLDLLIST_P(obj);	spl_ptr_llist_element *current = intern->llist->head, *next;	zval tmp, dllist_array;	zend_string *pnstr;	int  i = 0;	*is_temp = 0;	if (intern->debug_info == NULL) {		ALLOC_HASHTABLE(intern->debug_info);		zend_hash_init(intern->debug_info, 1, NULL, ZVAL_PTR_DTOR, 0);	}	if (intern->debug_info->u.v.nApplyCount == 0) {		if (!intern->std.properties) {			rebuild_object_properties(&intern->std);		}		zend_hash_copy(intern->debug_info, intern->std.properties, (copy_ctor_func_t) zval_add_ref);		pnstr = spl_gen_private_prop_name(spl_ce_SplDoublyLinkedList, "flags", sizeof("flags")-1);		ZVAL_LONG(&tmp, intern->flags);		zend_hash_add(intern->debug_info, pnstr, &tmp);		zend_string_release(pnstr);		array_init(&dllist_array);		while (current) {			next = current->next;			add_index_zval(&dllist_array, i, &current->data);			if (Z_REFCOUNTED(current->data)) {				Z_ADDREF(current->data);			}			i++;			current = next;		}		pnstr = spl_gen_private_prop_name(spl_ce_SplDoublyLinkedList, "dllist", sizeof("dllist")-1);		zend_hash_add(intern->debug_info, pnstr, &dllist_array);		zend_string_release(pnstr);	}	return intern->debug_info;}
开发者ID:AmesianX,项目名称:php-src,代码行数:48,


示例19: spl_heap_object_get_debug_info_helper

static HashTable* spl_heap_object_get_debug_info_helper(zend_class_entry *ce, zval *obj, int *is_temp) { /* {{{ */	spl_heap_object *intern  = Z_SPLHEAP_P(obj);	zval tmp, heap_array;	zend_string *pnstr;	int  i;	*is_temp = 0;	if (!intern->std.properties) {		rebuild_object_properties(&intern->std);	}	if (intern->debug_info == NULL) {		ALLOC_HASHTABLE(intern->debug_info);		ZEND_INIT_SYMTABLE_EX(intern->debug_info, zend_hash_num_elements(intern->std.properties) + 1, 0);	}	if (intern->debug_info->u.v.nApplyCount == 0) {		zend_hash_copy(intern->debug_info, intern->std.properties, (copy_ctor_func_t) zval_add_ref);		pnstr = spl_gen_private_prop_name(ce, "flags", sizeof("flags")-1);		ZVAL_LONG(&tmp, intern->flags);		zend_hash_update(intern->debug_info, pnstr, &tmp);		zend_string_release(pnstr);		pnstr = spl_gen_private_prop_name(ce, "isCorrupted", sizeof("isCorrupted")-1);		ZVAL_BOOL(&tmp, intern->heap->flags&SPL_HEAP_CORRUPTED);		zend_hash_update(intern->debug_info, pnstr, &tmp);		zend_string_release(pnstr);		array_init(&heap_array);		for (i = 0; i < intern->heap->count; ++i) {			add_index_zval(&heap_array, i, &intern->heap->elements[i]);			if (Z_REFCOUNTED(intern->heap->elements[i])) {				Z_ADDREF(intern->heap->elements[i]);			}		}		pnstr = spl_gen_private_prop_name(ce, "heap", sizeof("heap")-1);		zend_hash_update(intern->debug_info, pnstr, &heap_array);		zend_string_release(pnstr);	}	return intern->debug_info;}
开发者ID:AmesianX,项目名称:php-src,代码行数:47,


示例20: php_com_get_id_of_name

/* map an ID to a name */HRESULT php_com_get_id_of_name(php_com_dotnet_object *obj, char *name,		size_t namelen, DISPID *dispid){	OLECHAR *olename;	HRESULT hr;	zval *tmp;	if (namelen == -1) {		namelen = strlen(name);	}	if (obj->id_of_name_cache && NULL != (tmp = zend_hash_str_find(obj->id_of_name_cache, name, namelen))) {		*dispid = (DISPID)Z_LVAL_P(tmp);		return S_OK;	}		olename = php_com_string_to_olestring(name, namelen, obj->code_page);	if (obj->typeinfo) {		hr = ITypeInfo_GetIDsOfNames(obj->typeinfo, &olename, 1, dispid);		if (FAILED(hr)) {			hr = IDispatch_GetIDsOfNames(V_DISPATCH(&obj->v), &IID_NULL, &olename, 1, LOCALE_SYSTEM_DEFAULT, dispid);			if (SUCCEEDED(hr)) {				/* fall back on IDispatch direct */				ITypeInfo_Release(obj->typeinfo);				obj->typeinfo = NULL;			}		}	} else {		hr = IDispatch_GetIDsOfNames(V_DISPATCH(&obj->v), &IID_NULL, &olename, 1, LOCALE_SYSTEM_DEFAULT, dispid);	}	efree(olename);	if (SUCCEEDED(hr)) {		zval tmp;		/* cache the mapping */		if (!obj->id_of_name_cache) {			ALLOC_HASHTABLE(obj->id_of_name_cache);			zend_hash_init(obj->id_of_name_cache, 2, NULL, NULL, 0);		}		ZVAL_LONG(&tmp, *dispid);		zend_hash_str_update(obj->id_of_name_cache, name, namelen, &tmp);	}		return hr;}
开发者ID:AmesianX,项目名称:php-src,代码行数:48,


示例21: PHP_METHOD

/** * Resets the request and internal values to avoid those fields will have any default value */PHP_METHOD(Phalcon_Tag, resetInput){	zval *value = NULL, *key = NULL;	zval *a0 = NULL;	zval *g0 = NULL;	HashTable *ah0;	HashPosition hp0;	zval **hd;	char *hash_index;	uint hash_index_len;	ulong hash_num;	int hash_type;	PHALCON_MM_GROW();	PHALCON_ALLOC_ZVAL_MM(a0);	array_init(a0);	phalcon_update_static_property(SL("phalcon//tag"), SL("_displayValues"), a0 TSRMLS_CC);	phalcon_get_global(&g0, SL("_POST")+1 TSRMLS_CC);	if (!phalcon_valid_foreach(g0 TSRMLS_CC)) {		return;	}		ALLOC_HASHTABLE(ah0);	zend_hash_init(ah0, 0, NULL, NULL, 0);	zend_hash_copy(ah0, Z_ARRVAL_P(g0), NULL, NULL, sizeof(zval*));	zend_hash_internal_pointer_reset_ex(ah0, &hp0);	fes_9b93_0:		if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){			goto fee_9b93_0;		}				PHALCON_INIT_VAR(key);		PHALCON_GET_FOREACH_KEY(key, ah0, hp0);		PHALCON_INIT_VAR(value);		ZVAL_ZVAL(value, *hd, 1, 0);		phalcon_array_unset(g0, key);		zend_hash_move_forward_ex(ah0, &hp0);		goto fes_9b93_0;	fee_9b93_0:	zend_hash_destroy(ah0);	efree(ah0);			PHALCON_MM_RESTORE();}
开发者ID:meibk,项目名称:cphalcon,代码行数:48,


示例22: Z_MYSQLI_P

HashTable *mysqli_object_get_debug_info(zval *object, int *is_temp){	mysqli_object *obj = Z_MYSQLI_P(object);	HashTable *retval, *props = obj->prop_handler;	mysqli_prop_handler *entry;	ALLOC_HASHTABLE(retval);	ZEND_INIT_SYMTABLE_EX(retval, zend_hash_num_elements(props) + 1, 0);	ZEND_HASH_FOREACH_PTR(props, entry) {		zval rv, member;		zval *value;		ZVAL_STR(&member, entry->name);		value = mysqli_read_property(object, &member, BP_VAR_IS, 0, &rv);		if (value != &EG(uninitialized_zval)) {			zend_hash_add(retval, Z_STR(member), value);		}	} ZEND_HASH_FOREACH_END();
开发者ID:ronaldh02,项目名称:php-src,代码行数:18,


示例23: ALLOC_HASHTABLE

static HashTable *umsg_get_numeric_types(MessageFormatter_object *mfo,										 intl_error& err){	HashTable *ret;	int32_t parts_count;	if (U_FAILURE(err.code)) {		return NULL;	}	if (mfo->mf_data.arg_types) {		/* already cached */		return mfo->mf_data.arg_types;	}	const Formattable::Type *types = MessageFormatAdapter::getArgTypeList(		*(MessageFormat*)mfo->mf_data.umsgf, parts_count);	/* Hash table will store Formattable::Type objects directly,	 * so no need for destructor */	ALLOC_HASHTABLE(ret);	zend_hash_init(ret, parts_count, NULL, arg_types_dtor, 0);	for (int i = 0; i < parts_count; i++) {		const Formattable::Type t = types[i];		if (zend_hash_index_update_mem(ret, (zend_ulong)i, (void*)&t, sizeof(t)) == NULL) {			intl_errors_set(&err, U_MEMORY_ALLOCATION_ERROR,				"Write to argument types hash table failed", 0);			break;		}	}	if (U_FAILURE(err.code)) {		zend_hash_destroy(ret);		efree(ret);		return NULL;	}	mfo->mf_data.arg_types = ret;	return ret;}
开发者ID:13572293130,项目名称:php-src,代码行数:43,


示例24: php_runkit_sandbox_parent_ctor

static zend_object_value php_runkit_sandbox_parent_ctor(zend_class_entry *ce){	php_runkit_sandbox_parent_object *objval;	zend_object_value retval;	if (RUNKIT_G(current_sandbox)) {		objval = ecalloc(1, sizeof(php_runkit_sandbox_parent_object));		objval->obj.ce = ce;		objval->self = RUNKIT_G(current_sandbox);	} else {		/* Assign a "blind" stdClass when invoked from the top-scope */		objval = ecalloc(1, sizeof(zend_object));		objval->obj.ce = zend_standard_class_def;	}	ALLOC_HASHTABLE(objval->obj.properties);	zend_hash_init(objval->obj.properties, 0, NULL, ZVAL_PTR_DTOR, 0);	retval.handle = zend_objects_store_put(objval, NULL, (zend_objects_free_object_storage_t)php_runkit_sandbox_parent_dtor, NULL);	retval.handlers = RUNKIT_G(current_sandbox) ? &php_runkit_sandbox_parent_handlers : zend_get_std_object_handlers();	return retval;}
开发者ID:TysonAndre,项目名称:runkit7,代码行数:22,


示例25: fcgi_read_request

static int fcgi_read_request(fcgi_request *req){	fcgi_header hdr;	int len, padding;	unsigned char buf[FCGI_MAX_LENGTH+8];	req->keep = 0;	req->closed = 0;	req->in_len = 0;	req->out_hdr = NULL;	req->out_pos = req->out_buf;	ALLOC_HASHTABLE(req->env);	zend_hash_init(req->env, 0, NULL, (void (*)(void *)) fcgi_free_var, 0);	if (safe_read(req, &hdr, sizeof(fcgi_header)) != sizeof(fcgi_header) ||	    hdr.version < FCGI_VERSION_1) {		return 0;	}	len = (hdr.contentLengthB1 << 8) | hdr.contentLengthB0;	padding = hdr.paddingLength;	while (hdr.type == FCGI_STDIN && len == 0) {		if (safe_read(req, &hdr, sizeof(fcgi_header)) != sizeof(fcgi_header) ||		    hdr.version < FCGI_VERSION_1) {			return 0;		}		len = (hdr.contentLengthB1 << 8) | hdr.contentLengthB0;		padding = hdr.paddingLength;	}	if (len + padding > FCGI_MAX_LENGTH) {		return 0;	}	req->id = (hdr.requestIdB1 << 8) + hdr.requestIdB0;	if (hdr.type == FCGI_BEGIN_REQUEST && len == sizeof(fcgi_begin_request)) {		char *val;		if (safe_read(req, buf, len+padding) != len+padding) {			return 0;		}		req->keep = (((fcgi_begin_request*)buf)->flags & FCGI_KEEP_CONN);		switch ((((fcgi_begin_request*)buf)->roleB1 << 8) + ((fcgi_begin_request*)buf)->roleB0) {			case FCGI_RESPONDER:				val = estrdup("RESPONDER");				zend_hash_update(req->env, "FCGI_ROLE", sizeof("FCGI_ROLE"), &val, sizeof(char*), NULL);				break;			case FCGI_AUTHORIZER:				val = estrdup("AUTHORIZER");				zend_hash_update(req->env, "FCGI_ROLE", sizeof("FCGI_ROLE"), &val, sizeof(char*), NULL);				break;			case FCGI_FILTER:				val = estrdup("FILTER");				zend_hash_update(req->env, "FCGI_ROLE", sizeof("FCGI_ROLE"), &val, sizeof(char*), NULL);				break;			default:				return 0;		}		if (safe_read(req, &hdr, sizeof(fcgi_header)) != sizeof(fcgi_header) ||		    hdr.version < FCGI_VERSION_1) {			return 0;		}		len = (hdr.contentLengthB1 << 8) | hdr.contentLengthB0;		padding = hdr.paddingLength;		while (hdr.type == FCGI_PARAMS && len > 0) {			if (len + padding > FCGI_MAX_LENGTH) {				return 0;			}			if (safe_read(req, buf, len+padding) != len+padding) {				req->keep = 0;				return 0;			}			if (!fcgi_get_params(req, buf, buf+len)) {				req->keep = 0;				return 0;			}			if (safe_read(req, &hdr, sizeof(fcgi_header)) != sizeof(fcgi_header) ||			    hdr.version < FCGI_VERSION_1) {				req->keep = 0;				return 0;			}			len = (hdr.contentLengthB1 << 8) | hdr.contentLengthB0;			padding = hdr.paddingLength;		}	} else if (hdr.type == FCGI_GET_VALUES) {		unsigned char *p = buf + sizeof(fcgi_header);		HashPosition pos;		char * str_index;		uint str_length;		ulong num_index;//.........这里部分代码省略.........
开发者ID:jormin,项目名称:php-src,代码行数:101,


示例26: PHP_METHOD

PHP_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,


示例27: msgpack_convert_object

//.........这里部分代码省略.........    }    switch (Z_TYPE_PP(value))    {        case IS_ARRAY:        {            char *key;            uint key_len;            int key_type;            ulong key_index;            zval **data;            HashPosition pos;            HashTable *ht, *ret;            HashTable *var = NULL;            int num;            ht = HASH_OF(*value);            ret = HASH_OF(return_value);            num = zend_hash_num_elements(ht);            if (num <= 0)            {                zval_ptr_dtor(value);                break;            }            /* string - php_only mode? */            if (ht->nNumOfElements != ht->nNextFreeElement                || ht->nNumOfElements != ret->nNumOfElements)            {                HashTable *properties = NULL;                HashPosition prop_pos;                ALLOC_HASHTABLE(var);                zend_hash_init(var, num, NULL, NULL, 0);                zend_hash_internal_pointer_reset_ex(ht, &pos);                for (;; zend_hash_move_forward_ex(ht, &pos))                {                    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)                    {                        zval *val;                        MSGPACK_CONVERT_COPY_ZVAL(val, data);                        if (msgpack_convert_string_to_properties(                                return_value, key, key_len, val, var) != SUCCESS)                        {                            zval_ptr_dtor(&val);                            MSGPACK_WARNING(                                "[msgpack] (%s) "                                "illegal offset type, skip this decoding",                                __FUNCTION__);                        }
开发者ID:LoosKonstantin,项目名称:msgpack,代码行数:67,


示例28: ZEND_METHOD

/* ArchiveWriter::__construct {{{ **/ZEND_METHOD(ArchiveWriter, __construct){	archive_file_t *arch = NULL;	int resource_id;	zval *this = getThis();	const char *error_string = NULL;	char *filename;	long error_num, filename_len, result, format=0, compression=0;	zend_error_handling error_handling;	zend_replace_error_handling(EH_THROW, ce_ArchiveException, &error_handling TSRMLS_CC);	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ll", &filename, &filename_len, &format, &compression) == FAILURE) {		zend_restore_error_handling(&error_handling TSRMLS_CC);		return;	}#if PHP_API_VERSION < 20100412	if (PG(safe_mode) && (!php_checkuid(filename, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {		zend_restore_error_handling(&error_handling TSRMLS_CC);		return;	}#endif	if (php_check_open_basedir(filename TSRMLS_CC)) {		zend_restore_error_handling(&error_handling TSRMLS_CC);		return;	}	arch = (archive_file_t *) emalloc(sizeof(archive_file_t));	arch->stream = NULL;	ALLOC_HASHTABLE(arch->entries);	zend_hash_init(arch->entries, 10, NULL, _archive_entries_hash_dtor, 0);	arch->mode = PHP_ARCHIVE_WRITE_MODE;	arch->buf = emalloc(PHP_ARCHIVE_BUF_LEN + 1);	arch->filename = estrndup(filename, filename_len);	arch->arch = archive_write_new();	switch (compression) {		case PHP_ARCHIVE_COMPRESSION_GZIP:			if (archive_write_add_filter_gzip(arch->arch) != ARCHIVE_OK) {				php_error_docref(NULL TSRMLS_CC, E_WARNING, "Gzip compression is not supported in this build");				zend_restore_error_handling(&error_handling TSRMLS_CC);				return;			}			break;		case PHP_ARCHIVE_COMPRESSION_BZIP2:			if (archive_write_add_filter_bzip2(arch->arch) != ARCHIVE_OK) {				php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bzip2 compression is not supported in this build");				zend_restore_error_handling(&error_handling TSRMLS_CC);				return;			}			break;		case 0: /* default value */		case PHP_ARCHIVE_COMPRESSION_NONE:			/* always supported */			break;		default:			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unsupported compression type %ld", compression);			zend_restore_error_handling(&error_handling TSRMLS_CC);			return;			break;	}	switch (format) {		case 0: /* default value */		case PHP_ARCHIVE_FORMAT_TAR:		case PHP_ARCHIVE_FORMAT_PAX_RESTRICTED:			archive_write_set_format_pax_restricted(arch->arch);			break;		case PHP_ARCHIVE_FORMAT_PAX:			archive_write_set_format_pax(arch->arch);			break;		case PHP_ARCHIVE_FORMAT_CPIO:			archive_write_set_format_cpio(arch->arch);			break;		case PHP_ARCHIVE_FORMAT_SHAR:			archive_write_set_format_shar(arch->arch);			break;		case PHP_ARCHIVE_FORMAT_USTAR:			archive_write_set_format_ustar(arch->arch);			break;		default:			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unsupported archive format: %ld", format);			zend_restore_error_handling(&error_handling TSRMLS_CC);			return;			break;	}	archive_write_set_bytes_per_block(arch->arch, DEFAULT_BYTES_PER_BLOCK);	result = archive_write_open(arch->arch, arch, _archive_open_clbk, _archive_write_clbk, _archive_close_clbk);	/* do not pad the last block */	archive_write_set_bytes_in_last_block(arch->arch, 1);//.........这里部分代码省略.........
开发者ID:liuyu121,项目名称:pecl-file_formats-archive,代码行数:101,


示例29: xsl_ext_function_php

//.........这里部分代码省略.........								node->ns = curns;							} else {								node = xmlDocCopyNodeList(domintern->document->ptr, node);							}							php_dom_create_object(node, &child, domintern);							add_next_index_zval(&args[i], &child);						}					}				}				break;			default:				str = (char *) xmlXPathCastToString(obj);				ZVAL_STRING(&args[i], str);				xmlFree(str);		}		xmlXPathFreeObject(obj);	}	fci.size = sizeof(fci);	fci.function_table = EG(function_table);	if (fci.param_count > 0) {		fci.params = args;	} else {		fci.params = NULL;	}	obj = valuePop(ctxt);	if (obj->stringval == NULL) {		php_error_docref(NULL, E_WARNING, "Handler name must be a string");		xmlXPathFreeObject(obj);		valuePush(ctxt, xmlXPathNewString((const xmlChar *) ""));		if (fci.param_count > 0) {			for (i = 0; i < nargs - 1; i++) {				zval_ptr_dtor(&args[i]);			}			efree(args);		}		return;	}	ZVAL_STRING(&handler, (char *) obj->stringval);	xmlXPathFreeObject(obj);	ZVAL_COPY_VALUE(&fci.function_name, &handler);	fci.symbol_table = NULL;	fci.object = NULL;	fci.retval = &retval;	fci.no_separation = 0;	/*fci.function_handler_cache = &function_ptr;*/	if (!zend_make_callable(&handler, &callable)) {		php_error_docref(NULL, E_WARNING, "Unable to call handler %s()", ZSTR_VAL(callable));		valuePush(ctxt, xmlXPathNewString((const xmlChar *) ""));	} else if ( intern->registerPhpFunctions == 2 && zend_hash_exists(intern->registered_phpfunctions, callable) == 0) {		php_error_docref(NULL, E_WARNING, "Not allowed to call handler '%s()'", ZSTR_VAL(callable));		/* Push an empty string, so that we at least have an xslt result... */		valuePush(ctxt, xmlXPathNewString((const xmlChar *) ""));	} else {		result = zend_call_function(&fci, NULL);		if (result == FAILURE) {			if (Z_TYPE(handler) == IS_STRING) {				php_error_docref(NULL, E_WARNING, "Unable to call handler %s()", Z_STRVAL(handler));				valuePush(ctxt, xmlXPathNewString((const xmlChar *) ""));			}		/* retval is == NULL, when an exception occurred, don't report anything, because PHP itself will handle that */		} else if (Z_ISUNDEF(retval)) {		} else {			if (Z_TYPE(retval) == IS_OBJECT && instanceof_function(Z_OBJCE(retval), dom_node_class_entry)) {				xmlNode *nodep;				dom_object *obj;				if (intern->node_list == NULL) {					ALLOC_HASHTABLE(intern->node_list);					zend_hash_init(intern->node_list, 0, NULL, ZVAL_PTR_DTOR, 0);				}				Z_ADDREF(retval);				zend_hash_next_index_insert(intern->node_list, &retval);				obj = Z_DOMOBJ_P(&retval);				nodep = dom_object_get_node(obj);				valuePush(ctxt, xmlXPathNewNodeSet(nodep));			} else if (Z_TYPE(retval) == IS_TRUE || Z_TYPE(retval) == IS_FALSE) {				valuePush(ctxt, xmlXPathNewBoolean(Z_LVAL(retval)));			} else if (Z_TYPE(retval) == IS_OBJECT) {				php_error_docref(NULL, E_WARNING, "A PHP Object cannot be converted to a XPath-string");				valuePush(ctxt, xmlXPathNewString((const xmlChar *) ""));			} else {				convert_to_string_ex(&retval);				valuePush(ctxt, xmlXPathNewString((xmlChar *) Z_STRVAL(retval)));			}			zval_ptr_dtor(&retval);		}	}	zend_string_release(callable);	zval_ptr_dtor(&handler);	if (fci.param_count > 0) {		for (i = 0; i < nargs - 1; i++) {			zval_ptr_dtor(&args[i]);		}		efree(args);	}}
开发者ID:guggemand,项目名称:php-src,代码行数:101,


示例30: zend_create_closure

ZEND_API void zend_create_closure(zval *res, zend_function *func, zend_class_entry *scope, zend_class_entry *called_scope, zval *this_ptr) /* {{{ */{	zend_closure *closure;	object_init_ex(res, zend_ce_closure);	closure = (zend_closure *)Z_OBJ_P(res);	if ((scope == NULL) && this_ptr && (Z_TYPE_P(this_ptr) != IS_UNDEF)) {		/* use dummy scope if we're binding an object without specifying a scope */		/* maybe it would be better to create one for this purpose */		scope = zend_ce_closure;	}	if (func->type == ZEND_USER_FUNCTION) {		memcpy(&closure->func, func, sizeof(zend_op_array));		closure->func.common.prototype = (zend_function*)closure;		closure->func.common.fn_flags |= ZEND_ACC_CLOSURE;		if (closure->func.op_array.static_variables) {			HashTable *static_variables = closure->func.op_array.static_variables;			ALLOC_HASHTABLE(closure->func.op_array.static_variables);			zend_hash_init(closure->func.op_array.static_variables, zend_hash_num_elements(static_variables), NULL, ZVAL_PTR_DTOR, 0);			zend_hash_apply_with_arguments(static_variables, zval_copy_static_var, 1, closure->func.op_array.static_variables);		}		if (UNEXPECTED(!closure->func.op_array.run_time_cache)) {			closure->func.op_array.run_time_cache = func->op_array.run_time_cache = zend_arena_alloc(&CG(arena), func->op_array.cache_size);			memset(func->op_array.run_time_cache, 0, func->op_array.cache_size);		}		if (closure->func.op_array.refcount) {			(*closure->func.op_array.refcount)++;		}	} else {		memcpy(&closure->func, func, sizeof(zend_internal_function));		closure->func.common.prototype = (zend_function*)closure;		closure->func.common.fn_flags |= ZEND_ACC_CLOSURE;		/* wrap internal function handler to avoid memory leak */		if (UNEXPECTED(closure->func.internal_function.handler == zend_closure_internal_handler)) {			/* avoid infinity recursion, by taking handler from nested closure */			zend_closure *nested = (zend_closure*)((char*)func - XtOffsetOf(zend_closure, func));			ZEND_ASSERT(nested->std.ce == zend_ce_closure);			closure->orig_internal_handler = nested->orig_internal_handler;		} else {			closure->orig_internal_handler = closure->func.internal_function.handler;		}		closure->func.internal_function.handler = zend_closure_internal_handler;		if (!func->common.scope) {			/* if it's a free function, we won't set scope & this since they're meaningless */			this_ptr = NULL;			scope = NULL;		}	}	ZVAL_UNDEF(&closure->this_ptr);	/* Invariant:	 * If the closure is unscoped or static, it has no bound object. */	closure->func.common.scope = scope;	closure->called_scope = called_scope;	if (scope) {		closure->func.common.fn_flags |= ZEND_ACC_PUBLIC;		if (this_ptr && Z_TYPE_P(this_ptr) == IS_OBJECT && (closure->func.common.fn_flags & ZEND_ACC_STATIC) == 0) {			ZVAL_COPY(&closure->this_ptr, this_ptr);		}	}}
开发者ID:Jyhwenchai,项目名称:Share,代码行数:65,



注:本文中的ALLOC_HASHTABLE函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ ALLOC_INIT_ZVAL函数代码示例
C++ ALLOC_GROW函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。