当前位置: 首页>>代码示例>>C++>>正文


C++ zend_string_free函数代码示例

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


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

示例1: php_password_salt_to64

static int php_password_salt_to64(const char *str, const size_t str_len, const size_t out_len, char *ret) /* {{{ */
{
    size_t pos = 0;
    zend_string *buffer;
    if ((int) str_len < 0) {
        return FAILURE;
    }
    buffer = php_base64_encode((unsigned char*) str, str_len);
    if (ZSTR_LEN(buffer) < out_len) {
        /* Too short of an encoded string generated */
        zend_string_release(buffer);
        return FAILURE;
    }
    for (pos = 0; pos < out_len; pos++) {
        if (ZSTR_VAL(buffer)[pos] == '+') {
            ret[pos] = '.';
        } else if (ZSTR_VAL(buffer)[pos] == '=') {
            zend_string_free(buffer);
            return FAILURE;
        } else {
            ret[pos] = ZSTR_VAL(buffer)[pos];
        }
    }
    zend_string_free(buffer);
    return SUCCESS;
}
开发者ID:pinepain,项目名称:php-src,代码行数:26,代码来源:password.c

示例2: zephir_get_global

/**
 * Gets the global zval into PG macro
 */
int zephir_get_global(zval *arr, const char *global, unsigned int global_length)
{
	zval *gv;
	zend_bool jit_initialization = PG(auto_globals_jit);
	zend_string *str = zend_string_init(global, global_length, 0);

	if (jit_initialization) {
		zend_is_auto_global(str);
	}

	zval_ptr_dtor(arr);
	ZVAL_UNDEF(arr);

	if (&EG(symbol_table)) {
		if ((gv = zend_hash_find(&EG(symbol_table), str)) != NULL) {
			if (Z_TYPE_P(gv) == IS_ARRAY) {
				ZVAL_COPY_VALUE(arr, gv);
				zend_string_free(str);
				return SUCCESS;
			}
		}
	}
	array_init(arr);
	zend_hash_update(&EG(symbol_table), str, arr);
	zend_string_free(str);
	return SUCCESS;
}
开发者ID:KorsaR-ZN,项目名称:zephir,代码行数:30,代码来源:main.c

示例3: memset

/* {{{ php_zlib_encode() */
static zend_string *php_zlib_encode(const char *in_buf, size_t in_len, int encoding, int level)
{
	int status;
	z_stream Z;
	zend_string *out;

	memset(&Z, 0, sizeof(z_stream));
	Z.zalloc = php_zlib_alloc;
	Z.zfree = php_zlib_free;

	if (Z_OK == (status = deflateInit2(&Z, level, Z_DEFLATED, encoding, MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY))) {
		out = zend_string_alloc(PHP_ZLIB_BUFFER_SIZE_GUESS(in_len), 0);

		Z.next_in = (Bytef *) in_buf;
		Z.next_out = (Bytef *) ZSTR_VAL(out);
		Z.avail_in = in_len;
		Z.avail_out = ZSTR_LEN(out);

		status = deflate(&Z, Z_FINISH);
		deflateEnd(&Z);

		if (Z_STREAM_END == status) {
			/* size buffer down to actual length */
			out = zend_string_truncate(out, Z.total_out, 0);
			ZSTR_VAL(out)[ZSTR_LEN(out)] = '\0';
			return out;
		} else {
			zend_string_free(out);
		}
	}

	php_error_docref(NULL, E_WARNING, "%s", zError(status));
	return NULL;
}
开发者ID:Furgas,项目名称:php-src,代码行数:35,代码来源:zlib.c

示例4: if

static zend_constant *zend_get_special_constant(const char *name, size_t name_len)
{
	zend_constant *c;
	static char haltoff[] = "__COMPILER_HALT_OFFSET__";

	if (!EG(current_execute_data)) {
		return NULL;
	} else if (name_len == sizeof("__COMPILER_HALT_OFFSET__")-1 &&
	          !memcmp(name, "__COMPILER_HALT_OFFSET__", sizeof("__COMPILER_HALT_OFFSET__")-1)) {
		const char *cfilename;
		zend_string *haltname;
		size_t clen;

		cfilename = zend_get_executed_filename();
		clen = strlen(cfilename);
		/* check for __COMPILER_HALT_OFFSET__ */
		haltname = zend_mangle_property_name(haltoff,
			sizeof("__COMPILER_HALT_OFFSET__") - 1, cfilename, clen, 0);
		c = zend_hash_find_ptr(EG(zend_constants), haltname);
		zend_string_free(haltname);
		return c;
	} else {
		return NULL;
	}
}
开发者ID:0xhacking,项目名称:php-src,代码行数:25,代码来源:zend_constants.c

示例5: intl_error_reset

/* {{{ clone handler for Transliterator */
static zend_object *Transliterator_clone_obj( zval *object )
{
	Transliterator_object *to_orig,
	                      *to_new;
	zend_object 		  *ret_val;
	intl_error_reset( NULL );

	to_orig = Z_INTL_TRANSLITERATOR_P( object );
	intl_error_reset( INTL_DATA_ERROR_P( to_orig ) );
	ret_val = Transliterator_ce_ptr->create_object( Z_OBJCE_P( object ) );
	to_new  = php_intl_transliterator_fetch_object( ret_val );

	zend_objects_clone_members( &to_new->zo, &to_orig->zo );

	if( to_orig->utrans != NULL )
	{
		zval			tempz; /* dummy zval to pass to transliterator_object_construct */

		/* guaranteed to return NULL if it fails */
		UTransliterator *utrans = utrans_clone( to_orig->utrans, TRANSLITERATOR_ERROR_CODE_P( to_orig ) );

		if( U_FAILURE( TRANSLITERATOR_ERROR_CODE( to_orig ) ) )
			goto err;

		ZVAL_OBJ(&tempz, ret_val);
		transliterator_object_construct( &tempz, utrans,
			TRANSLITERATOR_ERROR_CODE_P( to_orig ) );

		if( U_FAILURE( TRANSLITERATOR_ERROR_CODE( to_orig ) ) )
		{
			zend_string *err_msg;
err:

			if( utrans != NULL )
				transliterator_object_destroy( to_new );

			/* set the error anyway, in case in the future we decide not to
			 * throw an error. It also helps build the error message */
			intl_error_set_code( NULL, INTL_DATA_ERROR_CODE( to_orig ) );
			intl_errors_set_custom_msg( TRANSLITERATOR_ERROR_P( to_orig ),
				"Could not clone transliterator", 0 );

			err_msg = intl_error_get_message( TRANSLITERATOR_ERROR_P( to_orig ) );
			zend_throw_error( NULL, "%s", ZSTR_VAL(err_msg) );
			zend_string_free( err_msg ); /* if it's changed into a warning */
			/* do not destroy tempz; we need to return something */
		}
	}
	else
	{
		/* We shouldn't have unconstructed objects in the first place */
		php_error_docref( NULL, E_WARNING,
			"Cloning unconstructed transliterator." );
	}

	return ret_val;
}
开发者ID:IMSoP,项目名称:php-src,代码行数:58,代码来源:transliterator_class.c

示例6: php_info_print_html_esc

static int php_info_print_html_esc(const char *str, size_t len) /* {{{ */
{
	size_t written;
	zend_string *new_str;

	new_str = php_escape_html_entities((unsigned char *) str, len, 0, ENT_QUOTES, "utf-8");
	written = php_output_write(ZSTR_VAL(new_str), ZSTR_LEN(new_str));
	zend_string_free(new_str);
	return written;
}
开发者ID:PeeHaa,项目名称:php-src,代码行数:10,代码来源:info.c

示例7: zend_string_alloc

static zend_string *unserialize_str(const unsigned char **p, size_t len, size_t maxlen)
{
	size_t i, j;
	zend_string *str = zend_string_alloc(len, 0);
	unsigned char *end = *(unsigned char **)p+maxlen;

	if (end < *p) {
		zend_string_free(str);
		return NULL;
	}

	for (i = 0; i < len; i++) {
		if (*p >= end) {
			zend_string_free(str);
			return NULL;
		}
		if (**p != '\\') {
			ZSTR_VAL(str)[i] = (char)**p;
		} else {
			unsigned char ch = 0;

			for (j = 0; j < 2; j++) {
				(*p)++;
				if (**p >= '0' && **p <= '9') {
					ch = (ch << 4) + (**p -'0');
				} else if (**p >= 'a' && **p <= 'f') {
					ch = (ch << 4) + (**p -'a'+10);
				} else if (**p >= 'A' && **p <= 'F') {
					ch = (ch << 4) + (**p -'A'+10);
				} else {
					zend_string_free(str);
					return NULL;
				}
			}
			ZSTR_VAL(str)[i] = (char)ch;
		}
		(*p)++;
	}
	ZSTR_VAL(str)[i] = 0;
	ZSTR_LEN(str) = i;
	return str;
}
开发者ID:Freeaqingme,项目名称:php-src,代码行数:42,代码来源:var_unserializer.c

示例8: co_socket_onReadable

static int co_socket_onReadable(swReactor *reactor, swEvent *event)
{
    util_socket *sock = (util_socket *) event->socket->object;
    php_context *context = &sock->context;

    zval *retval = NULL;
    zval result;

    reactor->del(reactor, sock->fd);

    if (sock->timer)
    {
        swTimer_del(&SwooleG.timer, sock->timer);
        sock->timer = NULL;
    }

    int n = read(sock->fd, sock->buf->val, sock->nbytes);
    if (n < 0)
    {
        ZVAL_FALSE(&result);
        zend_string_free(sock->buf);
    }
    else if (n == 0)
    {
        ZVAL_EMPTY_STRING(&result);
        zend_string_free(sock->buf);
    }
    else
    {
        sock->buf->val[n] = 0;
        sock->buf->len = n;
        ZVAL_STR(&result, sock->buf);
    }
    int ret = coro_resume(context, &result, &retval);
    zval_ptr_dtor(&result);
    if (ret == CORO_END && retval)
    {
        zval_ptr_dtor(retval);
    }
    efree(sock);
    return SW_OK;
}
开发者ID:didiwuliu,项目名称:swoole-src,代码行数:42,代码来源:swoole_coroutine_util.c

示例9: php_info_print_html_esc

static int php_info_print_html_esc(const char *str, size_t len) /* {{{ */
{
	size_t written;
	zend_string *new_str;
	TSRMLS_FETCH();

	new_str = php_escape_html_entities((unsigned char *) str, len, 0, ENT_QUOTES, "utf-8" TSRMLS_CC);
	written = php_output_write(new_str->val, new_str->len TSRMLS_CC);
	zend_string_free(new_str);
	return written;
}
开发者ID:Frgituser,项目名称:php-src,代码行数:11,代码来源:info.c

示例10: ds_throw_exception

void ds_throw_exception(zend_class_entry *ce, const char *format, ...)
{
    va_list ap;
    zend_string *str;

    va_start(ap, format);
    str = vstrpprintf(0, format, ap);
    va_end(ap);

    zend_throw_exception(ce, str->val, 0);
    zend_string_free(str);
}
开发者ID:php-ds,项目名称:extension,代码行数:12,代码来源:common.c

示例11: stream_client_do_connect_blocking

void stream_client_do_connect_blocking(
        skyray_stream_client_t *self, zend_object *protocol_obj,
        zend_string *host, zend_long port, zval *return_value)
{
    int fd = stream_client_do_connect(host->val, port);

    if (fd < 0) {
        return;
    }

    zval zstream;

    object_init_ex(&zstream, skyray_ce_Stream);
    zend_object *stream = Z_OBJ_P(&zstream);

    skyray_stream_t * stream_intern = skyray_stream_from_obj(stream);
    skyray_stream_init_blocking(stream_intern, SR_TCP, fd, protocol_obj);

    skyray_stream_on_opened(stream_intern, SR_READABLE | SR_WRITABLE);

    if (!self->protocol_creator) {
        ZVAL_COPY(return_value, &zstream);
        return;
    }

    zend_string *buffer;

    ++GC_REFCOUNT(protocol_obj); //preventing protocol instance be free'd after connection closed.
    while((buffer = skyray_stream_read(stream_intern, 0))) {
        if (buffer->len == 0) {
            zend_string_free(buffer);
            break;
        }
        skyray_stream_on_data(stream_intern, buffer);
        zend_string_free(buffer);
    }

    RETURN_OBJ(protocol_obj);
}
开发者ID:Lucups,项目名称:Skyray,代码行数:39,代码来源:client.c

示例12: smart_str_appendl

PHPAPI char *php_url_scanner_adapt_single_url(const char *url, size_t urllen, const char *name, const char *value, size_t *newlen, int encode)
{
	char *result;
	smart_str surl = {0};
	smart_str buf = {0};
	smart_str url_app = {0};
	zend_string *encoded;

	smart_str_appendl(&surl, url, urllen);

	if (encode) {
		encoded = php_raw_url_encode(name, strlen(name));
		smart_str_appendl(&url_app, ZSTR_VAL(encoded), ZSTR_LEN(encoded));
		zend_string_free(encoded);
	} else {
		smart_str_appends(&url_app, name);
	}
	smart_str_appendc(&url_app, '=');
	if (encode) {
		encoded = php_raw_url_encode(value, strlen(value));
		smart_str_appendl(&url_app, ZSTR_VAL(encoded), ZSTR_LEN(encoded));
		zend_string_free(encoded);
	} else {
		smart_str_appends(&url_app, value);
	}

	append_modified_url(&surl, &buf, &url_app, PG(arg_separator).output);

	smart_str_0(&buf);
	if (newlen) *newlen = ZSTR_LEN(buf.s);
	result = estrndup(ZSTR_VAL(buf.s), ZSTR_LEN(buf.s));

	smart_str_free(&url_app);
	smart_str_free(&buf);

	return result;
}
开发者ID:LTD-Beget,项目名称:php-src,代码行数:37,代码来源:url_scanner_ex.c

示例13: smart_str_appendz

void smart_str_appendz(smart_str *buffer, zval *value)
{
    switch (Z_TYPE_P(value)) {
        case IS_STRING:
            smart_str_append(buffer, Z_STR_P(value));
            return;
        case IS_LONG:
            smart_str_append_long(buffer, Z_LVAL_P(value));
            return;
    }

    zend_string *str = zval_get_string(value);
    smart_str_append(buffer, str);
    zend_string_free(str);
}
开发者ID:php-ds,项目名称:extension,代码行数:15,代码来源:common.c

示例14: ZVAL_STRINGL

/* This function is meant to unify the headers passed to to mail()
 * This means, use PCRE to transform single occurrences of \n or \r in \r\n
 * As a second step we also eleminate all \r\n occurrences which are:
 * 1) At the start of the header
 * 2) At the end of the header
 * 3) Two or more occurrences in the header are removed so only one is left
 *
 * Returns NULL on error, or the new char* buffer on success.
 * You have to take care and efree() the buffer on your own.
 */
static zend_string *php_win32_mail_trim_header(char *header)
{

#if HAVE_PCRE || HAVE_BUNDLED_PCRE
	
	zend_string *result, *result2;
	zval replace;
	zend_string *regex;

	if (!header) {
		return NULL;
	}

	ZVAL_STRINGL(&replace, PHP_WIN32_MAIL_UNIFY_REPLACE, strlen(PHP_WIN32_MAIL_UNIFY_REPLACE));
	regex = zend_string_init(PHP_WIN32_MAIL_UNIFY_REPLACE, sizeof(PHP_WIN32_MAIL_UNIFY_REPLACE)-1, 0);

//zend_string *php_pcre_replace(zend_string *regex, char *subject, int subject_len, zval *replace_val, int is_callable_replace, int limit, int *replace_count);

	result = php_pcre_replace(regex,
							  header, (int)strlen(header),
							  &replace,
							  0,
							  -1,
							  NULL);

	if (NULL == result) {
		zval_ptr_dtor(&replace);
		zend_string_free(regex);
		return NULL;
	}

	ZVAL_STRING(&replace, PHP_WIN32_MAIL_RMVDBL_PATTERN);
	regex = zend_string_init(PHP_WIN32_MAIL_RMVDBL_PATTERN, sizeof(PHP_WIN32_MAIL_RMVDBL_PATTERN)-1, 0);

	result2 = php_pcre_replace(regex,
							   result->val, (int)result->len,
							   &replace,
							  0,
							  -1,
							  NULL);
	return result;
#else
	/* In case we don't have PCRE support (for whatever reason...) simply do nothing and return the unmodified header */
	return estrdup(header);
#endif
}
开发者ID:AmesianX,项目名称:php-src,代码行数:56,代码来源:sendmail.c

示例15: ion_buffer_read_all

zend_string * ion_buffer_read_all(ion_buffer * buffer) {
    size_t incoming_length = evbuffer_get_length(bufferevent_get_input(buffer));
    zend_string * data;

    if(!incoming_length) {
        return ZSTR_EMPTY_ALLOC();
    }

    data = zend_string_alloc(incoming_length, 0);
    ZSTR_LEN(data) = bufferevent_read(buffer, ZSTR_VAL(data), incoming_length);
    if (ZSTR_LEN(data) > 0) {
        ZSTR_VAL(data)[ZSTR_LEN(data)] = '\0';
        return data;
    } else {
        zend_string_free(data);
        return NULL;
    }
}
开发者ID:dreamsxin,项目名称:php-ion,代码行数:18,代码来源:ion_stream.c


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